Click here to Skip to main content
15,902,114 members

1 solution

You cannot change the url without redirecting, but you can change the url hash!

You can simply use the location setter to "redirect" to a hash. The page shouldn't reload.

You can use the hash to store whatever you like:

JavaScript
//not tested but might work
document.location.hash = "{blah:x,blah2:y}";
///////////////////
var hash = document.location.hash;
//hash = "#{blah:x,blah2:y}"
//You can add with json or whatever and use that object to save the page state
 
Share this answer
 
Comments
Andy Lanng 31-Aug-16 7:39am    
PS: I wish I'd known this when I wrote my first page app :S

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900