How to update address bar with new URL without reloading the page?

Recommended Answers

The short answer is quite simple , google “History js” , the real answer is never alter the address bar url IF you are going to provide different content from what anyone would get by entering the url you are changing to. When I mean that all content should be …

Jump to Post

All 3 Replies

The short answer is quite simple , google “History js” , the real answer is never alter the address bar url IF you are going to provide different content from what anyone would get by entering the url you are changing to. When I mean that all content should be the same , I mean ALL content (including meta tags , and everything). Otherwise is like mocking your visitor (if anyone don't care about his / her visitors luckily search engines do)

u can use this code

Example :
 function processAjaxData(response, urlPath){
     document.getElementById("content").innerHTML = response.html;
     document.title = response.pageTitle;
     window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);
 }
Member Avatar

Give an example of what you want and why you wish to do so. This could be meaningless. Would these changes be bookmarkable, and if so would they provide specific content different to the original, if you entered the new url manually?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.