cascade-import-dynamic-002.xht (1154B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Dynamic sheet append (<link>)</title> 5 <link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu"/> 6 <link rel="reviewer" title="Ian Hickson" href="mailto:ian@hixie.ch"/> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/selector.html" /> 8 <link rel="match" href="../reference/ref-this-text-should-be-green.xht"/> 9 <script type="text/javascript"> 10 var style = document.createElementNS("http://www.w3.org/1999/xhtml", "link"); 11 style.setAttribute("type", "text/css"); 12 style.setAttribute("rel", "stylesheet"); 13 style.setAttribute("href", "support/import-red.css"); 14 document.getElementsByTagName("head")[0].appendChild(style); 15 // note: when this runs, we've only parsed as far as the next line, 16 // so the style element below doesn't exist, so we "append" 17 // before that element. 18 </script> 19 <link rel="stylesheet" type="text/css" href="support/import-green.css" /> 20 </head> 21 <body> 22 <p class="import">This text should be green.</p> 23 </body> 24 </html>