转:https://blog.csdn.net/yhq1913/article/details/51991231
1 重新加载js的方法
- var head = $("head").remove("script[role='reload']");
- $("<scri" + "pt>" + "</scr" + "ipt>").attr({ role: 'reload', src: getRootPath()+"/js/video.js", type: 'text/javascript' }).appendTo(head);
2 重新加载css的方法
- var link = document.createElement("link");
- link.rel = "stylesheet";
- link.type = "text/css";
- link.href = getRootPath()+"/css/video.css";
- document.getElementsByTagName("head")[0].appendChild(link);
function getRootPath() {
//获得根目录
var strFullPath = window.document.location.href;
var strPath = window.document.location.pathname;
var pos = strFullPath.indexOf(strPath);
var prePath = strFullPath.substring(0, pos);
var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
return (prePath + postPath);
}