Join us and the lead editor of IRL, Mozilla's multi-award-winning podcast, for a behind-the-scenes look at the pod and to contribute your ideas for the next season, themed: "AI and ME." Mark your calendar and join our Community Call on Wednesday, Aug 7, 17:00–17:45 UTC. See you there!

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

href with scroll(0,0) no longer works!

  • 2 回覆
  • 4 有這個問題
  • 1 次檢視
  • 最近回覆由 cor-el

more options

Until the update to V36.01, I used scroll(0,0) in an href as a link to the top of the page - which worked fine. It no longer works for me. Any ideas?

Until the update to V36.01, I used scroll(0,0) in an href as a link to the top of the page - which worked fine. It no longer works for me. Any ideas?

被選擇的解決方法

Do you mean like this:

<a href="javascript:scroll(0,0)">To Top</a>

It seems this should still be supported, per MDN: https://developer.mozilla.org/docs/Web/API/Window/scroll

Does it make any difference if you use:

<a href="javascript:window.scroll(0,0)">To Top</a>

or to separate your event handler from the HTML:

<a href="#" onclick="window.scroll(0,0); return false;">To Top</a>
從原來的回覆中察看解決方案 👍 2

所有回覆 (2)

more options

選擇的解決方法

Do you mean like this:

<a href="javascript:scroll(0,0)">To Top</a>

It seems this should still be supported, per MDN: https://developer.mozilla.org/docs/Web/API/Window/scroll

Does it make any difference if you use:

<a href="javascript:window.scroll(0,0)">To Top</a>

or to separate your event handler from the HTML:

<a href="#" onclick="window.scroll(0,0); return false;">To Top</a>
more options

You could try #top instead if you only need to scroll to the top.

Did you check the Web Console (Firefox/Tools > Web Developer) for error messages?