标签 jq 下的文章

【动态创建script来加载-推荐】

function loadJS( url, callback ){

var script = document.createElement('script'),

    fn = callback || function(){};

script.type = 'text/javascript';



//IE

if(script.readyState){

    script.onreadystatechange = function(){

        if( script.readyState == 'loaded' || script.readyState == 'complete' ){

            script.onreadystatechange = null;

            fn();

        }

    };

}else{

    //其他浏览器

    script.onload = function(){

        fn();

    };

}

script.src = url;

document.getElementsByTagName('head')[0].appendChild(script);

}

//用法

loadJS('file.js',function(){

alert(1);

});

引用:https://www.cnblogs.com/telwanggs/p/11045773.html

document.onkeydown=function(e){
    if ($('.text-area').is(":focus")) {
        if(e.keyCode == 13 && e.ctrlKey){
            var changeText = $('text-area').val() + "\n";
            $('text-area').val(changeText);
        }else if(e.keyCode == 13){
            // 避免回车键换行
            e.preventDefault();
            $('.dsChat_send').click();
        }
    }
}

replace(正则不要用引号,'需要替换内容')

window.onbeforeunload = function() {
    if (confirm('您确定要退出页面吗?数据会自动保存') == true) {
        return true;
    } else {
        return false;
    }
    // event.returnValue = "您确定要退出页面吗?未登录将重新发起新会话!";
}