zoukankan      html  css  js  c++  java
  • 修正IE6 IE7的window.resize bug


    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <meta content="IE=6" http-equiv="X-UA-Compatible"/>
        <title>fix ie6 resize bug by 司徒正美</title>

        <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
        <title>Resize</title>
        <script type="text/javascript">
          if(!Array.prototype.map)
            Array.prototype.map = function(fn,scope) {
              var result = [],ri = 0;
              for (var i = 0,n = this.length; i < n; i++){
                if(i in this){
                  result[ri++]  = fn.call(scope ,this[i],i,this);
                }
              }
            return result;
          };

          var getWindowSize = function(){
            return ["Height","Width"].map(function(name){
              return window["inner"+name] ||
                document.compatMode === "CSS1Compat" && document.documentElement[ "client" + name ]
                || document.body[ "client" + name ]
            });
          }
          window.onload = function(){
            if(!+"\v1" && !document.querySelector) { // for IE6 IE7
              document.body.onresize = resize;
            } else {
              window.onresize = resize;
            }
            var text =  document.getElementById("text")
            function resize() {
              text.innerHTML = getWindowSize().join(" : ");
            }
          }
        </script>

      </head>
      <body>
        <h1>修正IE6 IE7中window.onresize 被多次执行的bug</h1>
        <div id="text">这里是用来显示窗口大小</div>


      </body>
    </html>

  • 相关阅读:
    java面试题
    [gcc]: unknown (64bit) [FAIL]
    一种基于Spring的java程序常量管理思路
    if (! +"\v1")的解释
    jQuery validation plugin
    oscache缓存技术
    基于jQuery开发的javascript模板引擎jTemplates
    编写好的CSS代码的13个忠告
    对 HTTP 304 的理解
    Hibernate N+1 问题
  • 原文地址:https://www.cnblogs.com/amylis_chen/p/1712699.html
Copyright © 2011-2022 走看看