FF4使用窗口事件onResize的问题
添加事件时,我们在 FF4 中遇到一些问题。看起来我们的事件被捕获并冻结了。最后我们在 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 中正常工作
We have some problem with FF4 when add event. Look like than our event is catched and freezed. And in final we have gray screen on 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>
And it`s normal work in IE7, Chrome, FF3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
alert("你好!");
我认为它会冻结您的页面。被调用的次数太多了。
请参阅输入字段 http://jsfiddle.net/FbEhD/ 的示例。
它显示事件处理程序被调用的次数。
alert("hello there!");
I think it freezes your page. It's called too many times.
See example with input field http://jsfiddle.net/FbEhD/.
It shows how many times event handler is called.