Vyhľadajte odpoveď

Vyhnite sa podvodom s podporou. Nikdy vás nebudeme žiadať, aby ste zavolali alebo poslali SMS na telefónne číslo alebo zdieľali osobné informácie. Nahláste prosím podozrivú aktivitu použitím voľby “Nahlásiť zneužitie”.

Learn More

Anchor tags not working? Hard to believe but linking to url#anchor seems not to work in FF

  • 4 odpovede
  • 32 má tento problém
  • 30 zobrazení
  • Posledná odpoveď od dejannina

more options

test1.html:

<html>
<body>
<a href="test2.html#anchor">Anchor link</a>
</body>
</html>

test2.html:
<html>
<body>
lots of text...so the window can scroll...

<a name="anchor">Here's the anchor</a>
more text
</html>
</body>

This works as expected in Chrome, but not in FF.

test1.html: <pre><nowiki><html> <body> <a href="test2.html#anchor">Anchor link</a> </body> </html> test2.html: <html> <body> lots of text...so the window can scroll... <a name="anchor">Here's the anchor</a> more text </html> </body> </nowiki></pre> This works as expected in Chrome, but not in FF.

Upravil(a) cor-el dňa

Všetky odpovede (4)

more options

I filled in test2 with a Wikipedia article and the anchor link works as expected in Firefox 12.

It may be caused by an interfering extension. See Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems.

more options

Works fine here to.
There may be problems with frames though.


data:text/html;base64,PGh0bWw+Cjxib2R5Pgo8YSBocmVmPSJodHRwOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL01IVE1MI0ZpcmVmb3giPkFuY2hvciBsaW5rPC9hPgo8L2JvZHk+CjwvaHRtbD4=
more options

I don't think you gave us a link, so here's a wild guess: If a script in the page changes the length of the page after loading then Firefox may scroll the wrong distance.

See this thread for an example where the script hid some elements: anchors on bottom half of page don't work -at- mozillaZine Forums.

There could be a similar problem if the script inserts new elements and lengthens the page content.


To test whether scripts are the culprit, turn off JavaScript and try the link again.

Edit > Preferences > Content

uncheck the box next to Enable JavaScript

Upravil(a) jscher2000 - Support Volunteer dňa

more options

I had the same problem, with some script in the page that changes the length of the page after loading. I fix the problem with next code:

$(document).ready(function () { var anchor_id = window.location.hash; if (anchor_id != "") {

             var new_position = $(anchor_id).offset(); 
             window.scrollTo(new_position.left,new_position.top); 

} });