document.location.reload(false) fails to go to #anchor
Code:
<a name="loc"></a>
<a href="#loc" onClick="document.location.href='#loc';document.location.reload(false);return false">Click here to go to your location</a>
When you click onto the link you should go to the page location marked by the anchor tag "loc", however, upon clicking you go to the top of the page and never redirected to the exact spot where your anchor tag is located. Why is that? I'm using IE6 (per requirement) as my platform.
I added "return false", to no avail, the results remained the same. I cannot go to my URL#anchor; it constantly goes to URL without the direction to the anchored spot on the URL
<a name="loc"></a>
<a href="javascript:return false" onClick="document.location.href='#loc';document.location.reload(false);return false">Click here to go to your location</a>
<a name="loc"></a>
<a href="javascript:return false" onClick="document.location.href='#loc';document.location.reload(false);return false">Click here to go to your location</a>
Tried that as well, same wrong results: never goes to url#loc, just to url
Ok, I misunderstood. Does the following not work as well? This is the standard way to do it. The few times I've actually used it , it works fine in IE6.
Code:
<a name="loc"></a>
<a href="#loc">Click here to go to your location</a>
that occurs because that is the way anchors are supposed to work.
In my previous example, in some browsers if the anchor you are trying to move to is already on the screen somewhere, they may not scroll so it is at the top of the current view.
there are plenty of scripts out there that will force ti to do so, it just depends on your needs.
<a name="loc"></a>
<a href="javascript:return false" onClick="document.location.hash='loc';document.location.reload(false);return false">Click here to go to the location</a>
To no avail I even tried replacing document.location.hash with window.location.hash, again, to no avail. I've run out of ideas
Bookmarks