方法一

使用绝对路径,稳妥引入js。适用于各种浏览器。
在js中加入代码:

var baseurl = window.location.protocol+'//'+window.location.host;

include_js(baseUrl + "/static/aesTools.js");
function include_js(file, target) {
    var js;
    if (target == undefined) {
        target = self;
    }
    var html_doc = target.document.getElementsByTagName('head')[0];
    js = target.document.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', file);
    html_doc.appendChild(js);
}

方法二

在js中加入代码:

document.write("<script src='aesTools.js'></script>")

方法三

在js中加入代码:

  document.createElement("script").setAttribute("src","aesTools.js");
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐