Friday 28 March 2014

How to Modify the URL without reloading the page - HTML5

Problem definition:

Sometimes we need to change the portion after the domain,


e.g. http://raymn.com/ -> http://www.raymn.in/example.html without reloading.


Solution:


Video


HTML5 introduced the history.pushState() and history.replaceState() methods, which allow you to add and modify history entries, respectively.


This new feature offers you a way to change the URL displayed in the browser through javascript without reloading the page. It will also create a back-button event and you even have a state object you can interact with.


Example


window.history.replaceState("object or string", "Title", "example.html");


Parameter 2: The “Title” string is intended to describe the new state, and will not change the title of the document as one might otherwise expect.

Parameter 3:  The url you want to change domain/example.html.

Downloadable Links

Download Change_URL_raymntechnologies.html

Tags

Modify url without reloading,

Html/js modify url without reloading,
Addressbar url modify without reloading

No comments:

Post a Comment