change url without redirecting using javascript

kb858 picture kb858 · Sep 16, 2012 · Viewed 95k times · Source

I would like to know how to change the url without redirecting like on this website http://dekho.com.pk/ads-in-lahore when we click on tabs the url changes but the page dosent reload completely. There are other questions on stackoverflow indicating that it is not possible but i would like to know how the above mentioned website have implemented it. Thanks

Answer

Mihai Iorga picture Mihai Iorga · Sep 16, 2012

use pushState:

window.history.pushState("", "", '/newpage');