Tuesday, August 14, 2018

html - Javascript redirect to hash from base url

The following is not working (I just get a reload):



            location.host += "/#settings";

location.reload();


How do I tell JS to navigate to a URL based on the existing url and totally reload that page (not just append the hash)?



This also does not work:



             window.location.href = "/#settings";



My base url is "http://localhost:sss/pricing"



I want to redirect to "http://localhost:sss/#settings" with a reload.



I don't want to type localhost anywhere.



Even this gives me settings#lol:



            var desiredBase = window.location.protocol + "//" + window.location.host + "/";
var path = '#lol';

window.location.href = desiredBase + path;
location.reload();

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...