Not long ago, I made a script for page skin switching and encountered a very difficult problem. There were three style files, namely, the first line of the two files had a line of import url(default.css For the import sentence, and the sample format was black.css.
<LINK rel = stylesheet type = text/CSS src = "black.css"/>
Introduce to the page and write the switching code in the beginning.
Document. stylesheets [0]. href = "blue.css ";
Normally in IE6, in IE7/8beta1, the ult.css pattern is lost, but the style defined by blue.css is successfully applied. In Firefox, the style cannot be executed at all. therefore, after referring to some compatibility methods, add an ID to the link label and name it lkstyle, that is
<Link id = "lkstyle" rel = "stylesheet" type = "text/CSS" href = "black.css"/>
The modified script is as follows:
VaR objstyle = Document. getelementbyid ("lkstyle ");
Objstyle. href = "";
Objstyle. href = "blue.css ";
These three codes can be run in Firefox/IE6/IE7/ie8beta, and the imported import style will not be lost during the switch.