Tuesday 14 August 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...