I'm almost done with my previous issue, but now I'm dealing with something more subtle and annoying.
I've got a page with some links like these ones:
<a href = "page.html#1">First content</a>
<a href = "page.html#2">Second content</a>
In the page page.html there is some javascript, something like this:
document.write (window.location.href);
So, I click on the first link, and I see (in a different frame) the page "page.html", correctly starting at anchor #1. At the end the javascript writes "page.html#1", and this is correct. Then I click on the second link, and I see the page "page.html" changing its starting point, now correctly set at anchor #2. But at the end of the page I still see "page.html#1", not "page.html#2" as I expected. I think this happens because the page is exactly the same as before, only the starting point changed, so the "location.href" was not changed, despite a difference in the hash.
Is there a way to solve the problem, and get the original location.href, the one with the correct hash?
document.write()functionality again instead of relying on the page reload to execute it for you.document.write()has been somewhat obsolete for some time now - you should probably leverage more proper DOM manipulation methods. Further readingwindow.location.hrefdoes identify the correct hash. It's just that your code is not executed again when navigating inside the page.