3

I have an element (in html)

 <image xlink:url="https://abc" id="my_ele">

I do

ele = document.getElementById("my_ele")
// Now want to get https://abc

This answer here Getting 'xlink:href' attribute of the SVG <image> element dynamically using JS in HTML DOM

says:

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

But I'm not really sure what that translates to in my example.

(btw, Google docs displays images like this, at least in Chrome. Don't know why they don't use a proper IMG tag.)

Community
  • 1
  • 1
user984003
  • 28,050
  • 64
  • 189
  • 285

1 Answers1

8
<image xlink:href="https://abc" id="my_ele">

and

ele = document.getElementById("my_ele")
var url = ele.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
Filo
  • 2,829
  • 1
  • 21
  • 36