| 1 | <html><head> |
|---|
| 2 | |
|---|
| 3 | <script> |
|---|
| 4 | var iCount = 0; |
|---|
| 5 | |
|---|
| 6 | function fnCreate32StyleSheets() |
|---|
| 7 | { |
|---|
| 8 | for (i=0 ; i < 32; i++) |
|---|
| 9 | { |
|---|
| 10 | |
|---|
| 11 | var head = document.getElementsByTagName("head")[0]; |
|---|
| 12 | var style = document.createElement("style"); |
|---|
| 13 | var div = document.createElement("div"); |
|---|
| 14 | style.setAttribute("type", "text/css"); |
|---|
| 15 | |
|---|
| 16 | document.body.appendChild(style); |
|---|
| 17 | style.styleSheet.cssText = '.button {color:red}'; |
|---|
| 18 | |
|---|
| 19 | StyleSheetCount.innerText = "Total Style Sheets = " + ++iCount |
|---|
| 20 | } |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | function fnAdd1Import() |
|---|
| 24 | { |
|---|
| 25 | var ss = document.createStyleSheet(); |
|---|
| 26 | |
|---|
| 27 | ss.addImport(); |
|---|
| 28 | ss.imports[0].addImport(); |
|---|
| 29 | ss.imports[0].imports[0].cssText = 'button {color:blue}'; |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | function fnAddManyImport() |
|---|
| 37 | { |
|---|
| 38 | try { |
|---|
| 39 | var ss = document.createStyleSheet(); |
|---|
| 40 | try { |
|---|
| 41 | fnCreateStyleSheets(); |
|---|
| 42 | } catch (e) { |
|---|
| 43 | } |
|---|
| 44 | for (i=0 ; i < 33; i++) { |
|---|
| 45 | ss.addImport(); |
|---|
| 46 | ss.imports[0].cssText = 'button {color:yellow}'; |
|---|
| 47 | StyleSheetCount.innerText = "Total Style Sheets = " + ++iCount |
|---|
| 48 | } |
|---|
| 49 | } finally { |
|---|
| 50 | alert(document.stylesheets.length + ss.imports.length); |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | </script> |
|---|
| 56 | |
|---|
| 57 | </head><body> |
|---|
| 58 | |
|---|
| 59 | <button onclick="fnCreate32StyleSheets()">fnCreate32StyleSheets</button> |
|---|
| 60 | <div id="StyleSheetCount"></div> |
|---|
| 61 | <button onclick="fnAdd1Import()">fnAdd1Import</button><br> |
|---|
| 62 | <button onclick="fnAddManyImport()">fnAddManyImport</button> |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | </body></html> |
|---|
| 66 | |
|---|