[Javascript] Impossible to dynamically add style sheets in IE?

Hakan M (Backbase) hakan at backbase.com
Tue Sep 28 16:43:02 CDT 2004


Included with this file is a test case that (from my testing) crashes 
Internet Explorer, all versions since 5.0. It's about dynamically adding 
stylesheets to a page, something that Internet Explorer only seems to be 
able to do about 30 times.

A quick explanation:

When looking at the page, you will see four headers, all of them have 
onclick-events running a function. The topmost header is adding the 
style tag by throwing the string '<style 
type="text/css">h1{background-color:green;}</style>' to an elements 
innerHTML-property. The second header does this 40 times in a loop.

The two lower header do nothing, but commented out are an attempt to use 
a DOM-method of setting the contents of a style-tag, together with the 
error it produces in IE. Note however that you can still crash IE 
without setting the contents of the style tag, it's simply a matter of 
creating them.

Both methods work in Mozilla and Opera.

If anybody feels the need to take this serious, and happen to come up 
with a solution, I would be very thankful to hear of it.

Regards,
H
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040928/c5157e7e/attachment.html>


More information about the Javascript mailing list