Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change URL without refreshing page like Google+?

When I was examining Google+, I'm surprized when I see usage of URLs. Google profile URLs change without refresing page. For example this is a photos tab URL: https://plus.google.com/104560124403688998123/photos When you click Videos tab, URL exactly goes to https://plus.google.com/104560124403688998123/videos without refreshing page. How Google coders success this?

like image 429
Murat Çorlu Avatar asked Jul 04 '11 23:07

Murat Çorlu


2 Answers

Have a look at the history object https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

Especially history.pushState and history.replaceState

(Should mention that this only works in modern browsers, for old ones use hashes).

like image 168
Andreas Jansson Avatar answered Oct 04 '22 23:10

Andreas Jansson


This is about HTML 5. take a look at "onpopstate event". For further information go to the link. http://spoiledmilk.dk/blog/html5-changing-the-browser-url-without-refreshing-page

like image 42
atilkan Avatar answered Oct 04 '22 21:10

atilkan