Why the new web Dropbox can change the URL without page refresh? [duplicate]

Possible Duplicate:
How to change the URL displayed in the browser without leaving the page
How to do awesome refreshless page changes like GitHub
Change browser URL and page content without reload and without using fragments

It is amazing! The new Dropbox web version can do this! It will do ajax request and change the url,but the page will not refresh!(not change the hash)

The url will change from https://www.dropbox.com/home/ to https://www.dropbox.com/home/Public.

You can try it.

How to achieve it?

Answers:

Answer

They're using HTML5 Pushstate:

http://badassjs.com/post/840846392/location-hash-is-dead-long-live-html5-pushstate

What is pushState?

The history object gains two new methods, pushState & replaceState, that allow us to change the current location of the browser without making an HTTP request. These new locations are stored in the browsers history so that both the back and forward button work as expected.

 history.pushState({foo: "bar"}, "foo page", "/foo")
Answer

This is something you can do within the same domain by using the history.pushState() method

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.