locked
Why doesn't this SVG onclick work in VS2017 JS UWP RRS feed

  • Question

  • I want to make a JavaScript-based UWP on VS2017, and I need to be able to set styles by using JavaScript in an SVG onclick event.  The only problem is that VS2017 UWPs don't support changing styles with JavaScript at all.  I've tried using all sorts of methods: using the setAttribute() command and using a dynamically changing styles with style.opacity='1' and style['opacity']='1'

    You can plug the following code into VS2017, and it will not work as intended:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    
    <svg width="300" height="300" viewBox="0 0 391 391" xmlns="http://www.w3.org/2000/svg">
    <rect  id="yeet" x="0" y="0" height="100" width="100" fill="#000000" stroke="#ffffff" opacity="0.5" onclick="yeet.style.opacity='1'" ondblclick="yeet.style.opacity='0.5'"></rect>
    </svg>
    


    Nothing seems to work, please help.

    Thursday, July 23, 2020 11:39 PM

All replies

  • Hi DarioilsuperStupidprogramisanje-ario,

    The code you share is used with html file, please check it:

    And then I have checked SVG onclick event, it seems that it doesn't support javascript.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, July 24, 2020 5:50 AM
  • Hi Dylan,

    Thanks for the explanation, I see that it's not supported :(

    Anyways do you know another way I can recreate what I was intending for with an alternate method?

    Thanks, Dario

    Friday, July 24, 2020 8:45 PM
  • Hi DarioilsuperStupidprogramisanje-ario,

    >>Anyways do you know another way I can recreate what I was intending for with an alternate method? 

    This question is beyond our support. Our forum is discussing about visual studio debugger, we suggest you could move to stack overflow with SVG and javascript tag for better support.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Monday, July 27, 2020 9:47 AM