平滑滚动在 Firefox 中不起作用,在 IE 中工作正常 [英] smooth scroll not working in firefox, works fine in IE

查看:73
本文介绍了平滑滚动在 Firefox 中不起作用,在 IE 中工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我心爱的 Firefox 在这方面输给了 IE.任何人都知道为什么这在 Firefox 中不起作用?(甚至不去锚点),但在 IE 中平滑滚动?

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;
        });
    }
});

适用于:

<a class="scroll" href="#27">test scroll</a>

PS:它是基于原型/脚本的.

PS: It is prototype/scriptaculous based.

推荐答案

我认为问题出在数字锚点上.根据标准,元素的 id 属性应该从字母开始.

I would suppose that the problem is in numerical anchor. According to standard id attribute of the element should start from the letter.

这篇关于平滑滚动在 Firefox 中不起作用,在 IE 中工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆