zoukankan      html  css  js  c++  java
  • js的一些应用技巧

    1.保持layer在最前面,而不被Iframe、Object所覆盖
     在Layer中再插Iframe 或 Object 设z-Index值
     <div z-Index:2><object xxx></object> #前面
     <div z-Index:1><object xxx></object> #后面
     <div id="Layer2" style="position:absolute; top:40;400px;
     height:95px;z-index:2"> height=100% width=100%>
     <iframe width=0 height=0></iframe>
     </div>
     <div id="Layer1" style="position:absolute; top:50;200px;
     height:115px;z-index:1">
     <iframe height=100% width=100%></iframe> 字串6
     </div>

    2. 取得控件的绝对位置
    //javascript
    <script language="javascript">
    function getIE(e){
    var t=e.offsetTop;
    var l=e.offsetLeft;
    while(e=e.offsetParent){
    t+=e.offsetTop;
    l+=e.offsetLeft;
    }
    alert("top="+t+"/nleft="+l);
    }
    </script>

       GetNowObjectPosition: function(a){
            this.obj = a;
            var b = a.offsetLeft;
            var c = a.offsetTop;
            var d = a.offsetParent;
            while (d != null) {
                if (d.tagName != "BODY") {
                    b += d.offsetLeft;
                    c += d.offsetTop;
                    d = d.offsetParent
                }
                else {
                    b += document.body.offsetLeft || 0;
                    c += document.body.offsetTop || 0;
                    break
                }
            }
            return {
                X: b,
                Y: c
            }
        },

               var c = MyUtility.GetNowObjectPosition(objPlaceID);
                newMask.style.top = c.Y + "px";
                newMask.style.left = c.X + "px";

     3.脚本永不出错
    <SCRIPT LANGUAGE="javascript">
    <!-- Hide
    function killErrors() {
    return true;
    }
    window.onerror = killErrors;
    // -->
    </SCRIPT>


     

  • 相关阅读:
    hdu 2222 Keywords Search
    Meet and Greet
    hdu 4673
    hdu 4768
    hdu 4747 Mex
    uva 1513 Movie collection
    uva 12299 RMQ with Shifts
    uva 11732 strcmp() Anyone?
    uva 1401
    hdu 1251 统计难题
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1597177.html
Copyright © 2011-2022 走看看