basic-shadow-4.html 737 B

1234567891011121314151617181920212223242526272829
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <script>
  5. function tweak() {
  6. var shadowDiv = document.createElement("div");
  7. shadowDiv.style.border = "10px solid green";
  8. var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
  9. shadowRoot.appendChild(shadowDiv);
  10. var orangeDiv = document.createElement("div");
  11. orangeDiv.style.border = "10px solid orange";
  12. var purpleDiv = document.createElement("div");
  13. purpleDiv.style.border = "10px solid purple";
  14. shadowRoot.appendChild(purpleDiv);
  15. shadowRoot.insertBefore(orangeDiv, purpleDiv);
  16. }
  17. </script>
  18. </head>
  19. <body onload="tweak()">
  20. <div id="outer">
  21. <div style="background-color:red;"></div>
  22. </div>
  23. </body>
  24. </html>