简体   繁体   中英

Changing the URL without reloading the page

I would like to know if it's possible to change the contents of the URL in the browser without reloading the page?

I use jQuery and Ajax to load new parts of my page. When I choose "product one", the direct link would be mysite.com/product1 and for "product two" would be mysite.com/product2 , but I don't want to reload the site to these pages.

its now possible with HTML_5..

chack this link... http://www.spoiledmilk.dk/blog/?p=1922

also facebook and google using this tric beside Hash(#) attribute

You will have to add hash # if you want to prevent page from reloading.

The css-tricks.com has an excellent screencast on that, have a look at:

Best Practices with Dynamic Content

This is possible in HTML5. See a demo here .

You can change the URL to another URL within the same domain, but can not change the domain for security reasons.

See the history interface in HTML5 specification for details.

只需使用这个

window.history.pushState("object or string", "Title", "/new-url");

Yes, it is possible using the HTML5 History API. Check this page and this example

You CAN do that. Though likely you'll need a modern browser. Have a look at this page: http://www.20thingsilearned.com/ created by the Google Chrome team (I used Chrome 9 to read it). Changing pages doesn't reload the entire web page, but changes the URL.

You can't. Only if you change the hash, like sAc told you.

But.. May I ask WHY?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM