Om de ûnderfining foar jo te ferbetterjen is tydlik de funksjonaliteit dan dizze website troch ûnderhâldswurk beheind. Wannear in artikel jo probleem net oplost en jo in fraach stelle wolle, kin ús stipemienskip jo helpe yn @FirefoxSupport op Twitter en /r/firefox op Reddit.

Sykje yn Support

Mij stipescams. Wy sille jo nea freegje in telefoannûmer te beljen, der in sms nei ta te stjoeren of persoanlike gegevens te dielen. Meld fertochte aktiviteit mei de opsje ‘Misbrûk melde’.

Mear ynfo

Dizze konversaasje is argivearre. Stel in nije fraach as jo help nedich hawwe.

why did scrolltop stop working in firefox 36?

  • 6 antwurd
  • 12 hawwe dit probleem
  • 1 werjefte
  • Lêste antwurd fan triggervorbs

more options

I have a scrollTop jquery script that has been working for years but does nothing since I loaded Firefox 36. The script still works under Chrome and IE, so it must be an issue with FF. The script is this: function scrollTo() { var e = document.getElementById("findname"); var x = e.options[e.selectedIndex].value; var $target = $('#'+ x); var targetOffset = $target.offset().top;

	$('html, body').animate({scrollTop: targetOffset-15}, 900);

}; And is activated by an onClick event: <input type="button" value="Click to find" onClick="scrollTo()"/>

I have a scrollTop jquery script that has been working for years but does nothing since I loaded Firefox 36. The script still works under Chrome and IE, so it must be an issue with FF. The script is this: function scrollTo() { var e = document.getElementById("findname"); var x = e.options[e.selectedIndex].value; var $target = $('#'+ x); var targetOffset = $target.offset().top; $('html, body').animate({scrollTop: targetOffset-15}, 900); }; And is activated by an onClick event: <input type="button" value="Click to find" onClick="scrollTo()"/>

Keazen oplossing

If I edit your button's onclick handler to your actual script, it works:

<input onclick="var e = document.getElementById('findname'); var x = e.options[e.selectedIndex].value; var $target = $('#'+ x); var targetOffset = $target.offset().top; $('html, body').animate({scrollTop: targetOffset-15}, 900);" class="switchbutton3" value="Click to find" type="button">

That makes me think that Firefox might be interpreting

onclick="scrollTo()"

to refer to the native window.scrollTo() function instead of your function. I don't know why that wasn't a problem in the past, but perhaps if you rename your function to something like scrollToName() that will resolve it?

Dit antwurd yn kontekst lêze 👍 1

Alle antwurden (6)

more options

From the liberal use of $, I assume you are using jQuery. Which version are you using?

more options

I'm using jquery-1.11.1.min.js

more options

I was going to try to build a test case in http://jsfiddle.net/ but actually this may be hard to test without a general idea of the length of your content. Is there any way you can post a page demonstrating the problem?

more options

http://www.greyhoundpets.com/greyhounds.php

Near the top of the page, you'll see a "Select name" pull-down list. Select a name and click on the "Click to find" button. This should scroll to the requested name, but does not.

BTW, if you scroll down the page you will see a "Top" button appear near the bottom right. This button also uses the jQuery scrollTop function and it still works in FF36.

more options

Keazen oplossing

If I edit your button's onclick handler to your actual script, it works:

<input onclick="var e = document.getElementById('findname'); var x = e.options[e.selectedIndex].value; var $target = $('#'+ x); var targetOffset = $target.offset().top; $('html, body').animate({scrollTop: targetOffset-15}, 900);" class="switchbutton3" value="Click to find" type="button">

That makes me think that Firefox might be interpreting

onclick="scrollTo()"

to refer to the native window.scrollTo() function instead of your function. I don't know why that wasn't a problem in the past, but perhaps if you rename your function to something like scrollToName() that will resolve it?

more options

That was exactly the problem - I renamed the function as you suggested and all is working again now. As you say, it's odd that this didn't appear to be an issue until FF36. Many thanks for taking the trouble to help me with this.