adding image namespace in svg through JS still doesn't show me the picture

后端 未结 2 366
野性不改
野性不改 2020-12-19 12:46

after working out getting the parameter through a scaled version of a picture, I am trying through Javascript adding the picture with the original size parameter in SVG.

相关标签:
2条回答
  • 2020-12-19 13:08

    You should never use getAttribute/setAttribute on attributes that have prefixes, see DOM 3 Core for more details on why.

    It will work just fine if you use

    getAttributeNS('http://www.w3.org/1999/xlink', 'href')

    and

    setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', your_url_here).

    0 讨论(0)
  • 2020-12-19 13:33

    Try creating the image with null namespace:

    var bild = document.createElementNS(null, 'image');
    
    0 讨论(0)
提交回复
热议问题