zoukankan      html  css  js  c++  java
  • commonjs

    window.onlineDebug = false;
    //window.onlineDebug = true;//上线的时候注释掉
    if(window.location.search.indexOf("onlineDebug=1")>-1)
        window.onlineDebug = true;
    //如果onlineDebug为true的话,表示线上的debug模式打开,那么随时可以报错误了,
    //onlineDebug 为false的话,那么有错也不会报出来
     /*
    if(!onlineDebug){
       if(data == ""){
            return;
       }
    }
    线上执行,线下不执行
    
    */
    //封装一下我们的on方法,
    var tool = {
        on:function(select,type,cb){
            if(typeof type =="function"){
                cb = type;
                type = 'click';
            }
            $('body').on(type,select,cb);
        }
    }
    function get_cookie(Name) {
        var search = Name + "="//查询检索的值
        var returnvalue = "";//返回值
        if (document.cookie.length > 0) {
            sd = document.cookie.indexOf(search);
            if (sd!= -1) {
                sd += search.length;
                end = document.cookie.indexOf(";", sd);
                if (end == -1)
                    end = document.cookie.length;
                //unescape() 函数可对通过 escape() 编码的字符串进行解码。
                returnvalue=unescape(document.cookie.substring(sd, end))
            }
        }
        return returnvalue;
    }
    //接收参数方法
    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    function addEvent(elem,event,fn) {
        if(elem.addEventListener){  
            elem.addEventListener(event,fn,false);  
        }else if (elem.attachEvent){  
            elem.attachEvent('on'+event,fn);  
        }else{  
            elem['on'+event]=fn;  
        }  
    }  
  • 相关阅读:
    设置圆角代码
    队列组的简单使用
    多线程的延时执行和一次性代码
    GCD线程间的通信
    GCD"牛逼的中枢调度器"
    线程间的通信
    KVO运行时
    iOS Programming Localization 本地化
    iOS Programming State Restoration 状态存储
    如何安装sql server2005 windows 8
  • 原文地址:https://www.cnblogs.com/coding4/p/6845331.html
Copyright © 2011-2022 走看看