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

后端 未结 2 368
野性不改
野性不改 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).

提交回复
热议问题