How to NOT redirect when using window.document.href

Hey. I use jQuery to β€œreplace” the page content with new information, but I am having a problem.

I DO NOT WANT TO USE HASH!

So, for example, I have this page:

http://mydomain.com/

the user clicks the Cold Page button and ajax sends a request:

http://mydomain.com/coolpage

and I want to change the link (address bar) to:

http://mydomain.com/coolpage

but when ajax request is sent, I cannot change the URL of the JS address bar. How could I do this without a hash?

+3
source share
4 answers

It is only supported in some web browsers. This is a new technology in HTML5. You can read more about this here: https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

+4

HTML5 api, , pushState().

.

+2

Got it!

It's that simple with the jquery plugin (address) Just look here and try it!

http://phpcode.eu/ajaxtest/

(feel free to use my code)

+1
source

You can use history.js that use the HTML5 history API if they are supported and use a hash if they are not supported. The syntax is the same as HTML5 ( pushState()).

There is no way to avoid hash in an older browser if you want to manipulate the URL

0
source

All Articles