smooth scroll not working in firefox, works fine in IE

假如想象 提交于 2020-01-17 01:10:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!