让IE浏览器只执行一次resize事件

让IE浏览器只执行一次resize事件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="UTF-8" />
<title></title>
</head>

<body style="margin:0px; ">
<div id="xxx" style="width:100%;height:0px"></div> //代替window的onresize事件
<div id="showbox" style="background-color:red;">
</div>

<script type="text/javascript">
var n = 0;//事件激发计数器
var timeHandle;//清除定时器
document.getElementById("xxx").attachEvent("onresize", setShowBoxBounds);
(function setShowBoxBounds(){
window.status = "resize" + n;
var w =document.documentElement.clientWidth;
var h =document.documentElement.clientHeight;
document.getElementById("showbox").style.width = (w) + "px";
document.getElementById("showbox").style.height = (h) + "px";
document.getElementById("xxx").detachEvent("onresize", setShowBoxBounds);//接触事件绑定
if(timeHandle)clearTimeout(timeHandle);
timeHandle =setTimeout('document.getElementById("xxx").attachEvent("onresize", setShowBoxBounds);',500);//半秒钟后再绑定
n++;
})();
</script>

</body>
</html> 本文转自suifei博客园博客,原文链接:http://www.cnblogs.com/Chinasf/archive/2008/12/03/1346502.html,如需转载请自行联系原作者
上一篇:AngularJS指令嵌套时link函数执行顺序的问题


下一篇:【错误记录】jar 执行错误 ( java.lang.UnsupportedClassVersionError: Unsupported major.minor version 52.0 )