Works in Explorer and Opera.
Unfortunately the original page of the discoverer is offline. I found a summary at milov.nl, but it doesn't contain all the code.
First of all let's review the trick itself. If you saw one or two alerts when entering this page the trick works in your browser. If you didn't see any alerts, it doesn't work. As far as I know it only works in Explorer (Windows and Mac) and Opera.
though, so if you'd repeat the
background-image: etc for another class or id, you still see one
As a second test I defined these styles for an element with
However, I did not put this element in my HTML. Explorer on Windows and Opera don't show the second alert, but Explorer on Mac does. Apparently Explorer Mac also parses styles for absent elements. Good to know.
So far so good, this simple example works. However, when I tried to actually do something useful I ran into the restrictions of this technique.
First of all there is some trouble with quotes. My very first test was:
Explorer Windows showed the alert fine, but Explorer Mac complained about the quotes. Opera did nothing. When I tried
Explorer Mac and Opera showed the alert fine, but Explorer Windows complained about the quotes. I'm not sure who's
right here, and avoided the problem by rewriting my test to use a variable
to hold the alert text. In a real script this would be a serious problem, though.
Then I tried to write a simple script that generates a random background image for an element. This was the only actual, practical use of the technique I could think of. I tried
and Explorer Windows wrote the image name to the document, incidentally destroying this page. It didn't work
document.write, either. At the moment I don't think generating a random background
image is at all possible.
Since this technique doesn't work in all browsers and cannot be used to actually insert dynamic content into a CSS file, it has no redeeming features whatsoever. Therefore I don't see any reason to use it.
But how about using it to make sure a certain script is only executed in Explorer and Opera? I advise against it, for three reasons:
If this technique is useful, we cannot count on it remaining restricted. On the other hand, if it is useless we don't need it anyway.