Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  12] [ 4]  / answers: 1 / hits: 36965  / 14 Years ago, thu, july 1, 2010, 12:00:00

I'm trying to add an onClick handler to an embedded object. The handler needs to execute a function which is in an external .js file which is linked to the current html file via <script src=....



Do I need to reference the function differently due to it being located elsewhere?



Here is the code as it currently stands (which does not work, but also does not produce any errors):



<embed src=svg/button.svg id=buttonEmbed width=95 height=53 
type=image/svg+xml onClick=buttonEvent('buttonClicked')/>

More From » svg

 Answers
125

You have to implement onclick inside the svg and link it to the external JavaScript function using javascript inside the svg. See the SVG wiki for examples.



Update: Apparently the SVG wiki is no more. No surprise that the best references I can now (quickly) find are on StackOverflow itself.



This answer describes how to implement onclick inside the svg.


[#96367] Sunday, June 27, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hector

Total Points: 726
Total Questions: 103
Total Answers: 100

Location: Seychelles
Member since Mon, Jun 28, 2021
3 Years ago
;