Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Mozilla Support में खोजें

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Javascript smooth scrolling doesn't work in Firefox

  • 1 प्रत्युत्तर दें
  • 1 यह समस्या है
  • 7 views
  • के द्वारा अंतिम प्रतियुतर Junk_Mail

more options

My issue is with website JavaScript code working on every browser but Firefox. I have a button at the bottom of my forum page to return the user to the top. It is enabled with smooth scroll and uses only a small bit of JavaScript, not Jquery. In every other browser, the page slides smoothly back up to the top. In Firefox, it jumps up abruptly; no scroll. While typing this, I don't see any options for enclosing the code in tags, so I'll try to place it here as is, and perhaps you can advise as to why Firefox won't play nice with the code?

<script>
(function(){
  gotop.addEventListener("click",scrollWindow);
  function scrollWindow(){  
 var speed = 1;
 var start = document.body.scrollTop;
 (function doit(){ 
      window.scrollTo(0, document.body.scrollTop - speed);
      if(document.body.scrollTop > start/2){
   speed = speed * 1.02;
          setTimeout(doit,0);  
  }else{
   if(speed / 1.02 > 1 && document.body.scrollTop > 0)speed = speed / 1.01;
          if(document.body.scrollTop > 0)setTimeout(doit,0);   
  }
 })();
 };
})();
</script>

I only have Ad Blocker Plus and Ghostery installed but this has been happening ever since I installed FF with no add-ons. It's FireFox 47.0 (Mac).

Thank you for any help.

My issue is with website JavaScript code working on every browser but Firefox. I have a button at the bottom of my forum page to return the user to the top. It is enabled with smooth scroll and uses only a small bit of JavaScript, not Jquery. In every other browser, the page slides smoothly back up to the top. In Firefox, it jumps up abruptly; no scroll. While typing this, I don't see any options for enclosing the code in tags, so I'll try to place it here as is, and perhaps you can advise as to why Firefox won't play nice with the code? <pre><nowiki> <script> (function(){ gotop.addEventListener("click",scrollWindow); function scrollWindow(){ var speed = 1; var start = document.body.scrollTop; (function doit(){ window.scrollTo(0, document.body.scrollTop - speed); if(document.body.scrollTop > start/2){ speed = speed * 1.02; setTimeout(doit,0); }else{ if(speed / 1.02 > 1 && document.body.scrollTop > 0)speed = speed / 1.01; if(document.body.scrollTop > 0)setTimeout(doit,0); } })(); }; })(); </script></nowiki></pre> I only have Ad Blocker Plus and Ghostery installed but this has been happening ever since I installed FF with no add-ons. It's FireFox 47.0 (Mac). Thank you for any help.

cor-el द्वारा सम्पादित

All Replies (1)

more options

I do see this error in the console:

ReferenceError: scrollWindow is not defined onclick()

I'm not sure how to fix that, if that's the issue, since any fix I guess at might affect the function in other browsers.