• 让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="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>
    
    
  • 相关阅读:
    AVL树
    快速排序
    基数排序LSD_Radix_Sort
    归并排序
    JDBC连接池与工具类
    cookie的基础以及小案例
    javase基础4
    tomcat的request和response小案例
    javase基础3
    Servlet以及一个简单的登录案例
  • 原文地址:https://www.cnblogs.com/Chinasf/p/1346502.html
Copyright © 2020-2023  润新知