js导入外部脚本文件
2016-03-22 11:54
423 查看
JS 语言没找到导入外部脚本文件的功能,只能通知宿主程序来处理。
function include(path){
var a=document.createElement("script");
a.type = "text/javascript";
a.src=path;
var head=document.getElementsByTagName("head")[0];
head.appendChild(a);
}
可以在任何地方以
include("xxx.js");
include("http://baidu.com/xxx.js");
等等来包含外部的js
function include(path){
var a=document.createElement("script");
a.type = "text/javascript";
a.src=path;
var head=document.getElementsByTagName("head")[0];
head.appendChild(a);
}
可以在任何地方以
include("xxx.js");
include("http://baidu.com/xxx.js");
等等来包含外部的js
相关文章推荐
- js 格式化显示时间方法
- json 带斜杠时如何解析
- iOS js oc相互调用(JavaScriptCore)
- 介绍 JSON
- Js中String对象方法replace()用法详解
- js select option 选中触发事件
- JS日期比较大小 给定时间和持续时间计算最终时间
- js正则表达式中的问号几种用法小结
- 用JavaScript将数字转换为大写金额
- JavaScript计算指定日期与当前日期的相差天数
- JavaScript验证字符串只能包含数字或者英文字符的代码实例
- fastjson
- IE和Firefox的Javascript兼容性总结
- ejs里面如何判断某个参数是不是已经定义了?直接用会抛异常,直接判断也会。
- JS实现图片上传之前先预览
- Js获取URL及参数方法
- 简单jxl操作之jsp下载Excel
- js图表化工具
- JS判断数据类型
- Html+css+javascript总结