中山php|最优网络 :中山做网站 中山php建站
最优良人
Posts Tagged With: 异步加载
异步加载 Xheditor 的时候遇到的浏览器兼容问题
2011/08/14 at 02:55 » Comments (20)
由于各个浏览器对js代码的异步执行函数的支持不一样 window.execScript() 只支持IE浏览器 eval() 虽然支持各个浏览器,但是却不能在全局执行 解决的方法是利用javascript里面有一个改变上下文环境的关键字with . 把GetJsFile方法改成如下: function getJsFile(url, callBack){ var XH = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject('Msxml2.XMLHTTP'); XH.open('get',url,true); XH.onreadystatechange = function(){ if(XH.readyState == 4 && XH.status == 200){ with ( window )eval(XH.responseText); //if(window.execScript) window.execScript(XH.responseText); //else eval.call(window, XH.responseText); with ...more »