zoukankan      html  css  js  c++  java
  • js工具类

    var tools = {    
        fixE:function(e)
        {
            return e||window.event;
        },
        getOffset:function(obj,isleft)
        {
            var ab=0;
            while(obj!=null)
            {
                ab+=obj["offset"+(isleft?"Left":"Top")];
                obj=obj.offsetParent;
            };
            return ab;
        },
        getDistance:function(left,top,left2,top2)
        {
            return Math.sqrt(Math.pow(left-left2,2)+Math.pow(top-top2,2))
        },
        preventDefault:function(e)
        {
            e=this.fixE(e);
            if(e.preventDefaults)
                e.preventDefaults();
            else
                e.returnValue=false;
        },
        cancelBubble:function(e)
        {
          e=this.fixE(e);
          if(e.stopPropagation)
          {
                e.stopPropagation();
          }
          else
          {
                e.cancelBubble=true;
          }
        },
        disableSelection:function(target){
            if (typeof target.onselectstart!="undefined") //IE route
                target.onselectstart=function(){return false}
            else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
                target.style.MozUserSelect="none"
            else //All other route (ie: Opera)
                target.onmousedown=function(){return false}
            target.style.cursor = "default"
        }
    }
       
  • 相关阅读:
    poj 4005 Moles
    牛客 2C 圈圈
    牛客 2B 树 (组合计数)
    AC日记——校门外的树(增强版) 洛谷 P1276
    AC日记——寻找道路 洛谷 P2296
    AC日记——挤牛奶 洛谷 P1204
    AC日记——最大数 洛谷 P1198 [JSOI2008]
    AC日记——中位数 洛谷 P1168
    AC日记——校门外的树 洛谷 P1047
    AC日记——约瑟夫问题 codevs 1282
  • 原文地址:https://www.cnblogs.com/applesuch5/p/2162002.html
Copyright © 2011-2022 走看看