Alertnative CSS selection using Javascript (IE)

This is a discussion on "Alertnative CSS selection using Javascript (IE)" within the JavaScript Forum section. This forum, and the thread "Alertnative CSS selection using Javascript (IE) are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 19th, 2005, 15:41
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Alertnative CSS selection using Javascript (IE)

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>
Reply With Quote

  #2 (permalink)  
Old Jul 20th, 2005, 11:10
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
i dont think you looked at the whole page, keep reading, it definately shows you how to setup links to switch the styles!
Reply With Quote
Reply

Tags
alertnative, css, selection, using, javascript

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
File Selection in ASP wbeetge Starting Out 0 Oct 3rd, 2007 16:10
Forced Selection In a popup window Jamie18 JavaScript Forum 0 Jun 18th, 2007 18:58
Content Appears Based on Drop-Down Menu Selection WiseWizards JavaScript Forum 3 Aug 9th, 2005 17:48
Alternative CSS Selection (IE) Andy K Web Page Design 3 Jul 30th, 2005 04:31
IE6 Text selection bug Smokie Web Page Design 9 Jun 1st, 2005 20:12


All times are GMT. The time now is 19:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43