You need to wait until the SVG is loaded and than you can access the contentDocument:
var mySVG = document.getElementById("SVG");
var svgDoc;
mySVG.addEventListener("load",function() {
svgDoc = mySVG.contentDocument;
alert("SVG contentDocument Loaded!");
}, false);
More Related Contents:
- How to check if an embedded SVG document is loaded in an html page?
- Add SVG element to existing SVG using DOM
- Is it possible to use HTML’s .querySelector() to select by xlink attribute in an SVG?
- Accessing a DOM object defined in an external SVG file
- SVG get text element width
- How do I manipulate the SVG DOM and create elements?
- Create a table in SVG
- How to find event listeners on a DOM node in JavaScript or in debugging?
- Is there a spec that the id of elements should be made global variable?
- Check if an element contains a class in JavaScript?
- Chrome extension – retrieving global variable from webpage
- How can I loop through ALL DOM elements on a page?
- Changing SVG image color with javascript
- JavaScript DOM: Find Element Index In Container
- How to create Document objects with JavaScript
- Adding an onclick event to a table row
- Unable to understand useCapture parameter in addEventListener
- “Access is denied” JavaScript error when trying to access the document object of a programmatically-created (IE-only)
- Change ‘s option and trigger events with JavaScript
- How to unload a javascript from an html?
- How to draw a path smoothly from start point to end point in D3.js
- Should I use document.createDocumentFragment or document.createElement
- How to get nodes lying inside a range with javascript?
- Why does JavaScript navigator.appName return Netscape for Safari, Firefox and Chrome?
- jQuery/Javascript – How to wait for manipulated DOM to update before proceeding with function
- Is it possible to get element’s numerical index in its parent node without looping?
- Is there any way of passing additional data via custom events?
- What damage is done by document.write()? [duplicate]
- In JavaScript, how can I replace text in an HTML page without affecting the tags?
- Removing element with jQuery?