Reputation: 5663
Here i have a URL in Browser Address bar i want to replace path of Address bar using jQuery. Some try from my side is as below Consider url as below
http://localhost/catID/10/itemID/20
when i run
history.pushState("CatID", "Title", "21")
it change location bar as
http://localhost/catID/10/itemID/21
but i want result as
http://localhost/catID/21
how can i do this using jQuery
Upvotes: 2
Views: 2087
Reputation: 10240
Query not needed. Plain js will do. Just add this code in your function and replace the string with the required arguments. Try it in the console, for an immediate effect ;D
window.location = "http://localhost/catID/10"
If you do not want to reload the page or use # for changing the url, then use window.onpopstate
Modify the URL without reloading the page
Read this article on mozilla site.
Upvotes: 1