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>

  • 相关阅读:
    SqQueue(环状队列(顺序表结构))
    LinkQueue(链队列)
    CharMatch(括号匹配)
    LinkStack
    x-boot
    安装npm及cnpm(Windows)
    sourcetree跳过注册的方法
    Mysql 5.7 CentOS 7 安装MHA
    ORA-12519 ORA-12516
    lisp : set 与setq 函数
  • 原文地址:https://www.cnblogs.com/amylis_chen/p/1712699.html
Copyright © 2011-2022 走看看