I have a website with one main stylesheet (which is always loaded) and six alternate stylesheets of which one of them could be loaded on top of the main stylesheet.
How can I run Javascript when the stylesheet is changed using the menu of the browser? (So for instance after clicking on View, Page style, etc. in Mozilla Firefox)
And how can I access alternate stylesheets in Javascript?
I can use
document.styleSheets[0]
to access the main stylesheet, but I can’t access the alternate stylesheets that way. I want to dynamically change and add (insertRule) some CSS into one of my alternate stylesheets, so that’s why I need access to it.
My site doesn’t support Internet Explorer, so I don’t care if it works in IE or not: it’s fine as long as it works in the latest versions of Mozilla Firefox, Google Chrome, Apple Safari and Opera.