1. Used to load necessary files in external CSS files
@importurl(style.css);
//Can only be used in CSS files or style tags
2. Simply load an external CSS file into the page
document.createStyleSheet(cssFile);
2. Use the createElement method to create a CSS Link tag
varhead=document.getElementsByTagName('HEAD ').item(0);
varstyle=document.createElement('link');
style.href='style.css';
style.rel='stylesheet';
style .type='text/css';
head.appendChild(style);
The following are two functions that are often used.
functionloadJs(file){
varscriptTag=document.getElementById('loadScript');
varhead=document.getElementsByTagName(' head').item(0);
if(scriptTag)head.removeChild(scriptTag);
script=document.createElement('script');
script.src="../js/ mi_" file ".js";
script.type='text/javascript';
script.id='loadScript';
head.appendChild(script);
}
functionloadCss (file){
varcssTag=document.getElementById('loadCss');
varhead=document.getElementsByTagName('head').item(0);
if(cssTag)head.removeChild(cssTag) ;
css=document.createElement('link');
css.href="../css/mi_" file ".css";
css.rel='stylesheet';
css.type='text/css';
css.id='loadCss';
head.appendChild(css);
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn