Forum Moderators: open
This is to allow page anchors to function within Firefox
$(document).ready(function(){
$(window.location.hash).append('<a name="' + window.location.hash.replace('#','')+ '"></a>');
window.location.href=window.location.href;
});
<div id="foo">
Some content
...
More content
</div>
<div id="foo">
Some content
...
More content
<a name="foo"></a>
</div>
window.location.href=window.location.href;
I don't really understand what the purpose of this script is, since browsers will correctly jump to elements with a matching id value as the hash. Are you trying to get the browser to jump to the END of the element?
Also, I don't know what you mean about the lines showing on the active html page or requiring CSS file placement.
Do they present a vulnerability to the server? Only a potential Denial of Service attack in the event that a URL with no hash value is entered.
Hijacking of links? Nope.
It was also my understanding that it may only be used once per page
Page anchors "<a name>" allow links to specific portions of the page. As many time per page as you wish.
The pages function fine with the standard URl absent the anchor. No loop and pages load immediately.
If I insert those script lines in a page <head></head>
Than when the page is displayed, the script appears as text at the pages top.
With the script in a CSS file (which the same page utilizes) the script does not appear on page anywhere.