Find the ID from object-tag in svg

D

dutzend

Hi NG,

I must find the ID of the object-Tag from within the SVG.

<object data="test.svg" type="image/svg+xml" id="extern1"></object>

I try in TEST.SVG for example:

<svg onload="alert(document.parent.id)" ...>

I must get the id "extern1". Can somebody help?

Thx
René Tuchscherer
 
D

dhtmlkitchen

Hi NG,

I must find the ID of the object-Tag from within the SVG.

<object data="test.svg" type="image/svg+xml" id="extern1"></object>

I try in TEST.SVG for example:

<svg onload="alert(document.parent.id)" ...>

I must get the id "extern1". Can somebody help?

Thx
René Tuchscherer

can you dump it to the console?


<svg onload="console.dir( this )" ...>

Then explore the dom in the console until you find a property with the
value "external"

It might be possible to pass it in:
data="test.svg?id=external"

but that violates DRY. (and is lame).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top