Dette websted vil have begrænset funktionalitet, mens vi gennemgår vedligeholdelse for at forbedre din oplevelse. Hvis en artikel ikke løser dit problem, og du vil stille et spørgsmål, har vi vores supportfællesskab, der venter på at hjælpe dig på @FirefoxSupport på Twitter og/r/firefox på Reddit.

Søg i 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.

Læs mere

Javascript smooth scrolling doesn't work in Firefox

  • 1 svar
  • 1 har dette problem
  • 7 visninger
  • Seneste svar af 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.

Ændret af cor-el den

Alle svar (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.