【问题标题】:FF4 problem with use window event onResize使用窗口事件 onResize 的 FF4 问题
【发布时间】:2011-09-03 08:06:41
【问题描述】:

我们在添加事件时遇到了一些问题。看起来我们的事件被捕获并冻结了。最后,我们在 FF4 上出现灰屏

<html>
<head>
<script type="text/javascript">
function addEvent(elem, type, eventHandle) {
    if (elem == null || elem == undefined) return;
    if ( elem.addEventListener ) {
        elem.addEventListener( type, eventHandle, false );
    } else if ( elem.attachEvent ) {
        elem.attachEvent( "on" + type, eventHandle );
    }
};

addEvent(window, "resize", function() { alert("hello there!");  } );
</script>
</head>
<body>
test resize page
</body>
</html>

在IE7、Chrome、FF3下都可以正常使用

【问题讨论】:

  • Firefox 的首选缩写是“Fx”或“fx”

标签: javascript html events firefox4


【解决方案1】:

alert("hello there!");

我认为它会冻结您的页面。调用次数过多。

请参见输入字段 http://jsfiddle.net/FbEhD/ 的示例。 它显示了事件处理程序被调用的次数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-02
    • 1970-01-01
    • 1970-01-01
    • 2014-04-28
    • 1970-01-01
    • 2012-02-04
    • 1970-01-01
    相关资源
    最近更新 更多