问题
My beloved Firefox is losing to IE on this. Anyone know why this won't function in Firefox? (doesn't even go to anchor), but scrolls smoothly in IE?
document.observe("dom:loaded", function() {
if ($$('a.scroll')) {
$$('a.scroll').invoke('observe','click', function(event) {
Event.stop(event);
var elementLink = Event.element(event).readAttribute('href');
var scrollHere = elementLink.substr(1, elementLink.length);
Effect.ScrollTo(scrollHere);
return false;
});
}
});
applied as such:
<a class="scroll" href="#27">test scroll</a>
PS: It is prototype/scriptaculous based.
回答1:
I would suppose that the problem is in numerical anchor. According to standard id attribute of the element should start from the letter.
来源:https://stackoverflow.com/questions/7025535/smooth-scroll-not-working-in-firefox-works-fine-in-ie