This is splorp.

ISSN 1496-3221

May 28, 2003

Toggle switch.

I made the correct assumption in thinking that it was Safari’s implementation of document.styleSheets that was causing the Toggle CSS favelet to fail. This was confirmed on a couple of sites, specifically in an amazingly indepth JavaScript tutorial written by Mark Wilton-Jones. From the tutorial:

Konqueror and Safari [KHTML] incorrectly only populate the document.styleSheets collection with stylesheets that are enabled at any particular instant. The stylesheets cannot be disabled from here, and do not have the title property.

Bummer. However, as is common with many things programmatic, all is not entirely lost. The article goes on to say that even if the document.styleSheets collection is not supported (or improperly supported) it still may be possible to get an equivalent disabling or switching action by referencing the <link> and <style> tags instead. This isn’t the W3C recommended way of doing things, but you need to work with what you got. Half way is better than no way, I suppose. The most usable bit of scripting my friend John Charlton and I have been able to jury rig so far will toggle linked stylesheets, but not inline stylesheets — those confined within the <style> tags or using @import.

Toggle Linked CSS

Well, it’s a start. And to be completely honest, John hacked it together — I just made it look pretty. What else is new? Additional contributions and tweakage will be gratefully accepted. Now, if you don’t mind, I’m off to drop a couple of very specific bug fix request into Dave Hyatt’s mailbox.

This item was posted by Grant Hutchinson.

Categories:

Leave a comment or send a trackback from your own site.

Leave a comment.

Use these HTML elements and attributes to format your comment:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>