2

I have an SVG document which contains JavaScript code. As I asked here, I was trying to call a JavaScript function which was defined inside the SVG graphic from the loading HTML. I got an answer which linked to this page which explains how it works. However, it does not work in Google Chrome. Firefox does create all this correctly.

I was wondering if there is a one and only solution which appends the XML-Structure of the SVG file correctly to the DOM of the calling HTML and makes the Script callable. Is there a possibility using jQuery to simply load the file and append it on a div or something?

Thank you for your help!

Community
  • 1
  • 1
Florian Müller
  • 7,448
  • 25
  • 78
  • 120

1 Answers1

3

Here's an example of how to call a function in a script contained in an svg that is referenced from html with each of object, embed and iframe.

Your question is a bit unclear, you should consider posting the example you have that didn't work.

Erik Dahlström
  • 59,452
  • 12
  • 120
  • 139
  • 5.5 years after you supplied this answer the referenced svg document no longer contains any script functions. Do recall what the trick was/is to calling a script contained in an svg? – tobinjim Jan 30 '18 at 11:50
  • You are right, @tobinjim - something like https://stackoverflow.com/questions/2161388/calling-a-parent-window-function-from-an-iframe should work I think. – Erik Dahlström Jan 30 '18 at 15:04