Moveable Style II
October 15th, 2002Being unable to leave well enough alone, I’ve added another stylesheet (Salmon Roe) and an improved version of styleswitcher.js which also handles the Netscape 4 issue.
The first change in mystyleswitcher.js is setting the cookie at the time a new stylesheet is chosen, rather than when leaving the page as the original script did. This fixes the odd instances where you switched styles, then opened a comment window which then appeared in the previous style. I thought this was important for checking out stylesheets and also cutting down on cookie (re)setting in general, though if the cookie gets corrupted the user will get no style at all. (Thanks to Jade for discovering the bug.) That situation can always be rectified by selecting a new stylesheet manually.
The Netscape 4 handling is just something that seems to work. I changed the javascript function that was used to look up the first stylesheet (that was, the one with a rel=”stylesheet” instead of a rel=”stylesheet”) so
that it would look up a stylesheet with “Default” in its title instead. [I’m not doing it this way anymore - I just hardcoded the name of my default stylesheet to save computing time. To see the code for finding a stylesheet with “Default” in the title, check out the broken switcher. (That wasn’t the broken part.) To see the original code for finding the primary stylesheet, see the original switcher. The function is called getPreferredStyleSheet() in both places.]
In effect,
this gives two default stylesheets, one for browsers that can’t do the javascript switching at all (that is, the rel=”stylesheet” one), and another for browsers that can (with title=”Default …”). I already had a default stylesheet for this blog (Classic Khaki, whose real title is Default Khaki) as well as a version of it I’d dumbed down for Netscape 4 (Netscape 4 Khaki, a.k.a. For Older Browsers), so I
just put those in the appropriate spots.
Next time, I’ll make that Ume Shiso Maki stylesheet, and perhaps spruce up Lavender’s Blue.