0

I am creating mobile app using ionic framework. I have load SVG in my view as follow

<object id='svg-container' type="image/svg+xml" [data]="svgUrl" >
Your browser does not support SVG
</object>

When i trying to get SVG contentDocument with following code

var mySvg = document.getElementById("svg-container");
mySvg.addEventListener("load", function() {
    console.log((mySvg as HTMLObjectElement).contentDocument);
}, false);

Its working fine when SVG path is from internal assets folder, but it's not working when SVG loading from the server, its returning null in the content document


enter image description here In the screenshot, svg-container has a document loaded, but contentDocument is returning as null
How can I get inner document when SVG is loaded from URL, not from the asset folder.
It has nothing related to the website, I am looking for the solution for the hybrid mobile app.

Community
  • 1
  • 1
Divyesh Savaliya
  • 2,692
  • 2
  • 18
  • 37

0 Answers0