OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <svg id="svg" width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmln
s:xlink="http://www.w3.org/1999/xlink"> |
| 5 <rect width="100" height="100" fill="red"/> |
| 6 </svg> |
| 7 |
| 8 <script> |
| 9 var img = document.createElementNS('http://www.w3.org/2000/svg', 'image'); |
| 10 img.setAttribute('width', '100'); |
| 11 img.setAttribute('height', '100'); |
| 12 img.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'data:image/svg+x
ml,' + |
| 13 '<svg xmlns="http://www.w3.org/2000/svg">' + |
| 14 ' <rect width="100" height="100" fill="green"/>' + |
| 15 '</svg>'); |
| 16 |
| 17 var inactive_doc = document.implementation.createDocument ('http://www.w3.or
g/1999/xhtml', 'html', null); |
| 18 // First, insert into an inactive doc. |
| 19 inactive_doc.documentElement.appendChild(img); |
| 20 // Then re-insert into the current doc. |
| 21 document.getElementById('svg').appendChild(img); |
| 22 </script> |
| 23 </body> |
| 24 </html> |
OLD | NEW |