function requirecss(file, onLoad) {
var url = file;
if (file.indexOf("?") != -1) {
url = file.split("?")[0]
}
//监听键盘F5键与Ctrl+R键
document.onkeydown = function (e) {
e = e || window.event;
if ((e.ctrlKey && e.keyCode == 82) || e.keyCode == 116) {
window.localStorage.removeItem(url);
}
}
//监听浏览器刷新按钮与关闭按钮
window.onbeforeunload = function () {
window.localStorage.removeItem(url);
}
//检测是否需要加载css文件
if (window.localStorage.getItem(url) == null) {
var domLinkNode = document.createElement("link");
domLinkNode.async = true;
domLinkNode.rel = "stylesheet";
domLinkNode.type = "text/css";
domLinkNode.media = "screen";
domLinkNode.href = file;
document.body.appendChild(domLinkNode);
window.localStorage.setItem(url, url);
domLinkNode.onload = function () {
invokeFunc(onLoad);
}
} else {
invokeFunc(onLoad);
}
}