Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

I'm CSS challenged but trying my best...

I'd like to incorporate the methods from A List Apart article titled "Alternative Style: Working With Alternate Style Sheets", found here:

http://www.alistapart.com/articles/alternate/

However, I can't get it to work. The following error appears:

Error: Object expected

This is in the <head> section:

<link rel="stylesheet" type="text/css" href="StyleSheets/wide.css" title="default" media="screen" />
    
<link rel="alternate stylesheet" type="text/css" href="StyleSheets/wide_small.css" title="Smaller fonts" media="screen" />

<script type="text/javascript" src="StyleSheets/styleswitcher.js"></script>

And this is in the <body>

<a href="#" onclick="SetActiveStyleSheet('Smaller fonts'); return false;" title="Small fonts">sm</a>

So...when the page initially loads it does so with the default stylesheet: wide.css, but clicking on "sm" does not load the wide_small.css stylesheet as I hoped it would.

The styleswitcher.js file in the Stylesheets folder looks like this:

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

What am I doing wrong?

George Illes
Wednesday, February 04, 2004

JS is case-sensitive so check setActiveStyleSheet vs SetActiveStyleSheet

Hans van Leth
Thursday, February 05, 2004

> JS is case-sensitive so check setActiveStyleSheet vs
> SetActiveStyleSheet

Thanks Hans! That was the problem! (D-oh!)

George Illes
Thursday, February 05, 2004

*  Recent Topics

*  Fog Creek Home