load different css on different variable?

liunx

Guest
Hello,

is there a way to load an different stylesheet on different JavaScript variable?
With XML you should de something like:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
lcode = blabla
xmlDoc.load(lcode+"whatever.xml")
</SCRIPT>

Can you do something like that to load a different css when the lcode variable changes too?

The pages that will be in IFrames will check this lcode variable too to load there css, and that are a lot of pages, and the number of css files will be growing, so I don't want to set the different options before...

Thanx...Does this help at all?
<!-- m --><a class="postlink" href="http://www.alistapart.com/articles/alternate/">http://www.alistapart.com/articles/alternate/</a><!-- m -->

or any of these:
<!-- m --><a class="postlink" href="http://www.google.com/search?q=javascript+stylesheet+change&sourceid=mozilla-search&start=0&start=0&ie=utf-8&oe=utf-8I'm">http://www.google.com/search?q=javascri ... e=utf-8I'm</a><!-- m --> not an script wonder, but I tried to do the following after looking at the site <!-- m --><a class="postlink" href="http://www.alistapart.com/articles/alternate/">http://www.alistapart.com/articles/alternate/</a><!-- m -->:

<script language="javascript" type="text/javascript">
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
</script>

<body onLoad="setActiveStyleSheet('default');
return false;">

I made a css called default.css, but nothing happens...You need to add the title attribute to the link tag with the same name as the value passed to the JavaScript function. The CSS file name has no bearing on this script. You need title="default" in the link tag.

If you want another working example, try <!-- m --><a class="postlink" href="http://www.cm-life.com/?template=dptemplate6">http://www.cm-life.com/?template=dptemplate6</a><!-- m -->

That should clear things up.
 
Back
Top