import-svg-01.html 719 B

1234567891011121314151617181920212223
  1. <html class="reftest-wait">
  2. <head>
  3. <script>
  4. function setup() {
  5. var data =
  6. '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -100 50 100" width="100%" height="100%">' +
  7. ' <rect transform="rotate(180,0,0)" fill="red" x="-50" y="-50" width="100" height="100" />'+
  8. ' <rect fill="lime" x="-55" y="-55" width="110" height="110" />'+
  9. '</svg>';
  10. var drawing = document.getElementById("drawing");
  11. var parser = new DOMParser();
  12. var svg1 = document.importNode(parser.parseFromString(data, "text/xml").documentElement, true);
  13. drawing.appendChild(svg1);
  14. document.documentElement.className = "";
  15. }
  16. </script>
  17. </head>
  18. <body style="background-color: lime;" onload="setup()">
  19. <div id="drawing">
  20. </div>
  21. </body>
  22. </html>