crm动态载入js库

function load_script(url) {
    var xmlHTTPRequest;
    if (window.ActiveXObject) {
        xmlHTTPRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHTTPRequest = new XMLHttpRequest();
    }
    else {
        xmlHTTPRequest = new ActiveXObject("Msxml2.XMLHTTP");
    }
    xmlHTTPRequest.open('GET', url, false);
    xmlHTTPRequest.send('');
    eval(xmlHTTPRequest.responseText);
    var s = xmlHTTPRequest.responseText.split(/\n/);
    var r = /^(?

:function|var)\s*([a-zA-Z_]+)/i;
    for (var i = 0; i < s.length; i++) {
        var m = r.exec(s[i]);
        if (m != null) {
            window[m[1]] = eval(m[1]);
        }
    }
}
//事例
load_script("/WebResources/new_rest");

posted @ 2019-03-25 14:36  mqxnongmin  阅读(145)  评论(0编辑  收藏  举报