bumbu / svg-pan-zoom

JavaScript library that enables panning and zooming of an SVG in an HTML document, with mouse events or custom JavaScript hooks
https://github.com/ariutta/svg-pan-zoom#demos
BSD 2-Clause "Simplified" License
1.76k stars 389 forks source link

Unable to load SVG file from remote location path using Object element #368

Open rammohangowd opened 4 years ago

rammohangowd commented 4 years ago

Hi, I am trying to load SVG file from remote shared folder path in Object element in my angular 8 application, below is the code snippet.

<object id="svg1" xmlns:xlink="http://www.w3.org/1999/xlink" type="image/svg+xml" xmlns="http://www.w3.org/2000/svg" data="file://machinename/svg/test.svg"></object>

But when run application I am getting an error like "Not allowed to load local resource: file://machinename/svg/test.svg" in console.

Note: I am able to access the path from browser address bar directly: "file://machinename/svg/test.svg"

Is there anyway that I can resolve this issue.

shadowjustice commented 4 years ago

Hi!

You can't do it that way. I mean if I would open the web page it will not load since I do not have access to your machine.

The correct way to load a file through object is more like : <object id="demo-tiger" type="image/svg+xml" data="'assets/test.svg'" style="width: 500px; height: 500px; border:1px solid black; ">Your browser does not support SVG</object>

While my test.svg is in the assets folder image

I hope this helps you.