Topic: Style switching doesn't work in IE Pages that link to <a href="https://ozoneasylum.com/backlink?for=27819" title="Pages that link to Topic: Style switching doesn&amp;#039;t work in IE" rel="nofollow" >Topic: Style switching doesn&#039;t work in IE\

 
Author Thread
SPyX
Bipolar (III) Inmate

From: College Station, TX
Insane since: Aug 2002

IP logged posted posted 04-21-2006 19:36 Edit Quote

I took the code from the ALA article on style switchers and just added a check for windowwidth at the top. I do not really know javascript, but I was able to hack together this solution which works perfect in Firefox. I cannot however, figure out why IE doesn't like it.

code:
var windowWidth = window.innerWidth;
if ( windowWidth < 810 ) setActiveStyleSheet('smallWidth');

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;
     }
   }
}



You can see its implementation at http://robert-adam.com/proofs/djhomehealth/

Edit: Missing words.

(Edited by SPyX on 04-21-2006 19:37)

Hebedee
Paranoid (IV) Inmate

From: Maryland, USA
Insane since: Jan 2001

IP logged posted posted 04-21-2006 22:37 Edit Quote

http://www.javascripter.net/faq/browserw.htm

The property name is different in IE, because there is no standard for this value as far as I can tell.

(Edited by Hebedee on 04-21-2006 22:38)

SPyX
Bipolar (III) Inmate

From: College Station, TX
Insane since: Aug 2002

IP logged posted posted 04-21-2006 22:50 Edit Quote

You are my new favorite person. You win TWO internets.

-SPyX



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu