3

For example, if there are bookmarks:

https://gymhuntr.com/#37.3573,-122.0176
https://gymhuntr.com/#37.4504,-122.1791

Then if you bookmark them, and look at the first page, and then the second page, the second URL won't trigger reloading of the correct location, because the browser thinks it is the same page, but with different "hash tag".

So to make it work, we have to go to a totally different URL, such as google.com first, and then use the 2nd URL for it to work.

Is there a way to bookmark it so that it will work? (even by using a bookmarklet?)

1

You're right, the page doesn't reload just by changing the hash. You would think a bookmarklet could just do something like this:

javascript:(function() {
    location.href="http://google.com";
    location.href="https://gymhuntr.com/#37.3573,-122.0176";
})();

But that doesn't work because changing the url immediately causes the bookmarklet execution to stop, so the second location.href never gets set.

Even if you wrap the 2nd location.href in a setTimeout() and place it before changing the URL to google, it will still never execute.

If you don't care about opening a new tab you could do:

javascript:(function(){ open("https://gymhuntr.com/#37.3573,-122.0176")})()

But that doesn't sound like what you want. Fortunately this particular site forwards all calls to http to https, so the solution for this site (and probably most other HTTPS sites) is to change your two bookmarks to be:

http://gymhuntr.com/#37.3573,-122.0176
http://gymhuntr.com/#37.4504,-122.1791

And they will redirect to the proper HTTPS page and you can switch back and forth between them easily.

  • your final solution is like the hack of all hacks – user74542 Sep 20 '17 at 18:37
  • I am suspecting the window.location="...";window.location.reload() won't work in Google Chrome due to security concerns... if the site was already at that domain, then it will work, so the requirement is to first load the page with that particular domain before you can morph it with JavaScript – user74542 Sep 20 '17 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.