I have two different HTML pages using the same svg file I'm inserting with the tag.
The problem is I can retrieve the contentDocument in one of them but not the other. I opened inspect in both pages and the objects look exactly the same.
This is the one that does not work:
> document.getElementById("agvObj")
<object type="image/svg+xml" data="agv/agv.svg" class="agvObj" id="agvObj" height="100" width="100" style="visibility:hidden;">
#document
xml-stylesheet
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" id="agvSVG">…</svg>
</object>
> document.getElementById("agvObj").getSVGDocument()
null
> document.getElementById("agvObj").contentDocument
null
This is the one that works:
> document.getElementById("agvObj")
<object type="image/svg+xml" data="agv/agv.svg" class="agvObj" id="agvObj" height="100" width="100" style="visibility:hidden;">
#document
xml-stylesheet
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" id="agvSVG">…</svg>
</object>
> document.getElementById("agvObj").getSVGDocument()
#document
> document.getElementById("agvObj").contentDocument
#document
The object looks exactly the same, so I really don't know what else I should check to know why it works in one page and not the other.