[IE] use document.createStyleSheet to add CSS dynamically (closes #2356261)
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 22 May 2012 12:41:18 +0200
changeset 8412 09432a572a44
parent 8411 9ac2400cdf82
child 8425 b86bdc343c18
[IE] use document.createStyleSheet to add CSS dynamically (closes #2356261)
web/data/cubicweb.ajax.js
--- a/web/data/cubicweb.ajax.js	Mon May 21 14:17:09 2012 +0200
+++ b/web/data/cubicweb.ajax.js	Tue May 22 12:41:18 2012 +0200
@@ -181,8 +181,17 @@
                 // compute concat-like url for missing resources and append <link>
                 // element to $head
                 if (missingStylesheetsUrl) {
-                    $srcnode.attr('href', missingStylesheetsUrl);
-                    $srcnode.appendTo($head);
+                    // IE has problems with dynamic CSS insertions. One symptom (among others)
+                    // is a "1 item remaining" message in the status bar. (cf. #2356261)
+                    // document.createStyleSheet needs to be used for this, although it seems
+                    // that IE can't create more than 31 additional stylesheets with
+                    // document.createStyleSheet.
+                    if ($.browser.msie) {
+                        document.createStyleSheet(missingStylesheetsUrl);
+                    } else {
+                        $srcnode.attr('href', missingStylesheetsUrl);
+                        $srcnode.appendTo($head);
+                    }
                 }
             }
         });