I looked at several topics with a similar problem, however, these solutions did not help me. I have a div, with an object inside. I am trying to get DOM of the svg file, however it returns me null.
var svgobject = document.getElementById("34");
alert(svgobject); //ok
var svgdom = svgobject.contentDocument; //null
var selector = svgdom.querySelector('svg');
Also, i tried add something like this:
svgobject.addEventListener("load",function() {
var svgDoc = mySVG.contentDocument;
alert("SVG contentDocument Loaded!");
alert(svgDoc); //null
}, false);
And the result was the same..
HTML:
<div class="svgGenerator">
<object id = "34" data="images/generator.svg" type="image/svg+xml"></object>
</div>
How do i correctly get a contentDocument of my SVG file?