代码如下:
复制代码 代码如下:
var otherJScipt = document.createElement("script");
otherJScipt = document.createElement("script");
otherJScipt.setAttribute("type", "text/javascript");
otherJScipt.setAttribute("src", "/xxx.js");
document.getElementsByTagName("head")[0].appendChild(otherJScipt);//追加到head标签内
//判断服务器
if (navigator.userAgent.indexOf("IE") >= 0) {
//IE下的事件
otherJScipt.onreadystatechange = function () {
//IE下的判断,判断是否加载完成
if (otherJScipt && (otherJScipt.readyState == "loaded" || otherJScipt.readyState == "complete")) {
otherJScipt.onreadystatechange = null;
callMyFun();
}
};
}
else {
otherJScipt.onload = function () {
otherJScipt.onload = null;
callMyFun();
};
}
您可能感兴趣的文章:
- 使用jQuery动态加载js脚本文件的方法
- 如何使用jquery动态加载js,css文件实现代码
- jquery getScript动态加载JS方法改进详解
- javascript开发随笔二 动态加载js和文件
- Extjs入门之动态加载树代码
- 用ajax动态加载需要的js文件
- 动态加载js文件 document.createElement
- 高性能WEB开发 JS、CSS的合并、压缩、缓存管理
- 禁止js文件缓存的代码
- javascript的动态加载、缓存、更新以及复用(一)