1.在HTML頁面載入js文件的方法: 2.在HTML頁面載入css文件的方法: ...
1.在HTML頁面載入js文件的方法:
function loadScriptFile(filePath){
var script = document.createElement("script");
script.type = "text/javascript";
script.src = filePath;
document.head.appendChild(script);
}
2.在HTML頁面載入css文件的方法:
function loadCsstFile(filePath){
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "filePath";
document.head.appendChild(link);
//document.getElementsByTagName("head")[0].appendChild(link);
}