Accessing DOM elements in an embedded doc

J

Julius Mong

Dear all, I have something like this:

<html... >
<embed ...>
</html>

Am I out of luck if I wanted to access the embedded DOM and manipulate its
content?

Or if I have:

<svg ...>
<svg ...>
...
</svg ...>
</svg>

Is it possible to manipulate the inner svg elements from a script defined in
the outer? I tried

var SVGDoc = evt.getTarget().getOwnerDocument();
var SVGRoot = SVGDoc.getDocumentElement();
var SVGInner = SVGDoc.getElementsByTagName("svg");
SVGInner.currentTranslate.x += dx;

and it won't work, if I did:

var SVGDoc = evt.getTarget().getOwnerDocument();
var SVGRoot = SVGDoc.getDocumentElement();
SVGRoot.currentTranslate.x += dx;

then the entire outer document gets translated, I've also tried
SVGDoc.getElementByID and getfirstChild with no luck... can someone point me
in the right direction?

Thanks, Jules
 
M

Martin Honnen

Julius said:
Dear all, I have something like this:

<html... >
<embed ...>
</html>

Am I out of luck if I wanted to access the embedded DOM and manipulate its
content?

As browsers offer an <embed> element to embed content rendered by
plugins I am not sure what your example is, an attempt to provide a HTML
snippet which you script inside of a browser and where you then usually
be able to script the <embed> element if the plugin exposes an API to
JavaScript, or an attempt to define your own new element <embed> that is
supposed to embed on HTML document into another. If the latter I am
wondering why you do not use <iframe> or <object> as that are the tools
HTML 4 (or XHTML 1) provides to embed another HTML page. As for
accessing them, yes, inside of a browser and with the HTML DOM there are
properties, see
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-67133006
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-38538621
for contentDocument of an <iframe> or <object> element.

Of course if it is not inside of a browser and you are just using the
W3C DOM Core then it is diffifult. So you need to tell us how you are
going to use the DOM, with which language, which level and which modules
you have available.
Or if I have:

<svg ...>
<svg ...>
...
</svg ...>

Does SVG allow to nest said:
</svg>

Is it possible to manipulate the inner svg elements from a script defined in
the outer? I tried

var SVGDoc = evt.getTarget().getOwnerDocument();
var SVGRoot = SVGDoc.getDocumentElement();
var SVGInner = SVGDoc.getElementsByTagName("svg");
SVGInner.currentTranslate.x += dx;

and it won't work, if I did:

var SVGDoc = evt.getTarget().getOwnerDocument();
var SVGRoot = SVGDoc.getDocumentElement();
SVGRoot.currentTranslate.x += dx;

then the entire outer document gets translated, I've also tried
SVGDoc.getElementByID and getfirstChild with no luck... can someone point me
in the right direction?

Do you know about the Yahoo group for SVG developers? Maybe someone
there can answer your question
http://groups.yahoo.com/group/svg-developers/
 

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

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top