How could Javascript find what media-type related stylesheet has been selected by a Web browser?
I would like a particular piece of Javascript to 1) trigger
after external cascading style sheets have been loaded, then 2) figure out, in some fashion,
which style sheet has loaded (based on the media type, like "screen" or "handheld"). Essentially, I'm adding a lot of material via the DOM that I don't want cluttering up the HTML for handheld users, or the folks who have no CSS at all.
I'd like to keep this working with Internet Explorer, FireFox, Safari, Opera, etc. Using
:before and
:after to generate content via a rule like
content: url(somejavascriptfunction), then accessing that, won't work for IE 6.0.
I thought about trying to wait a second for the sheets to load (with a timer), then access the style of some element, a style that would be changed by an external style sheet, and then use that as a signal to see which style sheet was loaded. For some reason, I'm failing to access any style that either wasn't 1) inline CSS, 2) added by Javascript later.
Looking at the
stylesheet object for the
disabled property didn't work, either. althought
A List Apart had something that kinda-sorta looked helpful.
I'm out of the obvious ideas, and my Google searches have pointed me mostly at forcing style sheets, rather than figuring out which have been selected by a browser.
posted by null terminated at 3:33 PM on September 1, 2006