29
Views
2
Comments
Solved
Can I execute logic inside an SVG?
Application Type
Reactive

Hi there.

I have an SVG file, which I want to place on a screen of my application. I placed some JavaScript code inside of this SVG file using a <script> tag. I placed this SVG on my screen using an Image widget.

However, when I run the application, it's like the JavaScript code I wrote in there was ignored. Is there any way I can solve this? Or, maybe, is there another way to approach this? Maybe place the JavaScript code outside of the SVG?

Any help would be appreciated :)

UserImage.jpg
Yizuhi Galaviz
Solution

Hi. Thanks for your reply, I kept trying and eventually figured it out :)

I simply placed my SVG file inside of an <object> tag instead of an Image widget and my logic worked. 

2021-01-12 13-21-28
Kadu Borges

Hi Yizuhi,

Yes, it's possible to execute logic inside an SVG using javascript. Could you send me the svg file or the javascript that you are trying to use?

Best regards

UserImage.jpg
Yizuhi Galaviz
Solution

Hi. Thanks for your reply, I kept trying and eventually figured it out :)

I simply placed my SVG file inside of an <object> tag instead of an Image widget and my logic worked. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.