Rephrase the question. What is the best way to provide alternative style sheets for a document?
I have a list of style sheets, all of which are listed in the html file. I use javascript to disable just one file.
Example:
style1 disabled = false
style2 disabled = true
In practice, the last loaded stylesheet (style2) is active, regardless of the disabled property.
How can I alternate stylesheets in a document in chrome?
I tried to set the attribute value href, but it seems to be read-only.
example code that I used: (I use an object called MenuStyles that stores various css information)
function setActiveStyleSheet(name) {
var selectedSheet;
var currentSheet;
for (var i = 0; i < MenuStyles.styleSheets.length; i++) {
currentSheet = MenuStyles.styleSheets[i];
if (currentSheet.name === name) {
selectedSheet = currentSheet.sheetObj;
currentSheet.disabled = false;
} else {
currentSheet.disabled = true;
}
}
return selectedSheet;
}
EDIT: , . . :
function setActiveStyleSheet(name) {
var selectedSheet;
var currentSheet;
for (var i = 0; i < MenuStyles.styleSheets.length; i++) {
currentSheet = MenuStyles.styleSheets[i];
if (currentSheet.name === name) {
selectedSheet = currentSheet.sheetObj;
currentSheet.sheetObj.disabled = false;
} else {
currentSheet.sheetObj.disabled = true;
}
}
return selectedSheet;
}