动态加载JS和CSS文件(3)
cssFile.setAttribute('rel', 'stylesheet');
cssFile.setAttribute('href', urls[i]);
if (!hasFile("link", urls[i])) {
loadFile(cssFile, callback);
}
}
}
function loadScript(files, callback, parent) {
var urls = files && typeof (files) == "string" ? [files] : files;
for (var i = 0, len = urls.length; i < len; i++) {
var script = document.createElement("script");
script.setAttribute('charset', 'gb2312');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', urls[i]);
if (!hasFile("script", urls[i])) {
loadFile(script, callback, parent);
}
}
}
function includeFile(options) {
//首先加载css,再次加载script www.2cto.com
loadCssFile(options.cssFiles, function () {
//加载预备script
loadScript(JSLoader.scripts.jquery, function () {
//加载页面所需的script
相关新闻>>
- 发表评论
-
- 最新评论 更多>>