Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble programatically adding CSS to IE
    text
    copied!<p>I have a bookmarklet which inserts a CSS stylesheet into the target DOM via a "link" tag (external stylesheet).</p> <p>Recently, this stopped working on Amazon.com, in Internet Explorer only. It works on other sites, and with other browsers (even on Amazon.com). The technique we're using to insert the stylesheet is pretty straightforward:</p> <p><code>document.getElementsByTagName('head')[0].appendChild(s);</code></p> <p>Where "s" is a link object created with <code>document.createElement</code>. Even on Amazon, I see via the Internet Explorer Developer Toolbar DOM inspector that the element is there. <strong>However</strong> if I alert the <code>document.styleSheets</code> collection in JavaScript, it's not there. </p> <p>As a test, I tried to use the IE-only <a href="http://msdn.microsoft.com/en-us/library/ms531194(VS.85).aspx" rel="nofollow noreferrer">document.createStyleSheet</a> method passing the URL to my stylesheet as an argument. This throws the error:</p> <blockquote> <p>Not enough storage is available to complete this operation</p> </blockquote> <p>Points of interest:</p> <ul> <li>The documentation for <code>document.createStyleSheet</code> says an error will be thrown if there are more than 31 stylesheets on the page but (1) it's a different error, and (2) there are only 10 external stylesheets on the page.</li> <li>My googling for the error turned up a number of dead-ends, and the only one that suggested anything stylesheet-related was <a href="http://drupal.org/node/114188" rel="nofollow noreferrer">this drupal post</a>, but it refers to a character limit on inline styles, as opposed to a problem relating to external styles.</li> <li>The same code, even the <code>createStyleSheet</code> call, works on other sites in IE.</li> </ul> <p>Any advice would be appreciated. This has reached "complete mystery" status for me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload