标签:index esc attribute i++ asc node java css end
/** * 加载 script 文件 * @param src */ function loadScript(src) { var addSign = true; var scripts = document.getElementsByTagName("script"); for (var i = 0; i < scripts.length; i++) { if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) != -1) { addSign = false; } } if (addSign) { var $script = document.createElement(‘script‘); $script.setAttribute("type", "text/javascript"); $script.setAttribute("src", src); document.getElementsByTagName("head").item(0).appendChild($script); } }
/** * 加载 link 文件 * @param href */ function loadCss(href) { var addSign = true; var links = document.getElementsByTagName("link"); for (var i = 0; i < links.length; i++) { if (links[i] && links[i].href && links[i].href.indexOf(href) != -1) { addSign = false; } } if (addSign) { var $link = document.createElement("link"); $link.setAttribute("rel", "stylesheet"); $link.setAttribute("type", "text/css"); $link.setAttribute("href", href); document.getElementsByTagName("head").item(0).appendChild($link); } }
/** * 删除 script 文件 * @param src */ function removeScript(src) { var scripts = document.getElementsByTagName("script"); for (var i = 0; i < scripts.length; i++) { if (scripts[i] && scripts[i].src && scripts[i].src.indexOf(src) != -1) { scripts[i].parentNode.removeChild(scripts[i]); } } }
/** * 删除 link 文件 * @param href */ function removeCss(href) { var links = document.getElementsByTagName("link"); for (var i = 0; i < links.length; i++) { var _href = links[i].href; if (links[i] && links[i].href && links[i].href.indexOf(href) != -1) { links[i].parentNode.removeChild(links[i]); } } }
标签:index esc attribute i++ asc node java css end
原文地址:https://www.cnblogs.com/kinblog/p/11733870.html