window.onresize 在IE浏览器下有多次被执行甚至死循环的bug,会导致浏览器卡死
解决方案:
复制代码 代码如下:
// IE浏览器下将onresize事件放在div上
if(navigator.userAgent && navigator.userAgent.toLowerCase().indexOf("msie")>-1){
document.body.innerHTML = '<div onresize="resetClientWidth();lazyLoadImgesMethod();" style="width:100%;height:100%;position:absolute;z-index:-999;"></div>' + document.body.innerHTML;
} else {
window.onresize = function(){
resetClientWidth();
lazyLoadImgesMethod();
};
}
ps:FF浏览器不支持在div上写onresize事件,window.onresize 虽然在FF下不会死循环,但如果在函数里面有alert执行,FF浏览器也会卡死,很无奈的bug。
PS: navigator.userAgent.split(";")[1].toLowerCase().indexOf("msie")>-1 这个判断ie的问题, 在chrome浏览器下会出现"toLowerCase()"方法未定义的错误.
所以修正为navigator.userAgent.toLowerCase().indexOf("msie")>-1
最后
以上就是伶俐酒窝最近收集整理的关于IE下window.onresize 多次调用与死循环bug处理方法介绍的全部内容,更多相关IE下window.onresize内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复