Hello.
I am wanting to allow users to change
css stylesheets on my webpage, using links.
I have been following information from:
http://www.alistapart.com/articles/alternate/ but it doesn't explain how to set up the links.
I have two style sheets set up and I have added the Javascript to the page (see below)
How do I set up the <a href .. link to change the style sheet? and which variables do I update in the Javascript please?
- Code: Select all
<link href="GA_styles.css" rel="stylesheet" type="text/css" title="blue standard"/>
<link href="GA_styles2.css" rel="alternate stylesheet" type="text/css" title="different"/>
<script language="JavaScript" type="text/javascript">
HTMLLinkElement.getAttribute("rel").indexOf("style") != -1
HTMLListElement.getAttribute("title")
HTMLLinkElement.getAttribute("rel").indexOf("alt") != -1
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
</script>
</head>