How to access the content of the “embed” tag in HTML

Use .getSVGDocument(). This seems to work for <embed>, <object> and <iframe>:

document.getElementById('svgsource').getSVGDocument()

For <object> or <iframe> you can also use .contentDocument:

document.getElementById('svgsource').contentDocument

For IE7 or IE8, I believe you are out of luck.

Leave a Comment