W3C home > Mailing lists > Public > public-svg-ig@w3.org > April to June 2009

<iframe> accessing SVG DOM from SVG [was RE: Progress on SVG book -- question concerning <embed> vs <object> in HTML]

From: Dailey, David P. <david.dailey@sru.edu>
Date: Sun, 5 Apr 2009 14:42:47 -0400
Message-ID: <1835D662B263BC4E864A7CFAB2FEEB3D01525771@msfexch01.srunet.sruad.edu>
To: "Doug Schepers" <schepers@w3.org>
Cc: "SVG IG List" <public-svg-ig@w3.org>, <jferrai@us.ibm.com>
thanks Doug,
I had fussed that
>the only way I could find to access the SVG DOM
> through<iframe>  was to put a script in the SVG that upon loading
> sends its own SVGDocument as a parameter to a function running inside
> HTML. I may have seen another work around but (and I know I've seen
> suggestions that didn't work), but I still have that listed in my
> mind as an open problem.

Doug replied:

>It's actually not that bad... I think I do something similar here:
>  http://schepers.cc/svg/blendups/scriptbridge/scriptbridge.html

Yes, but as I see that example, what you've done is inside HTML:
canvas1 = document.getElementById( "canvas1" );
      canvas1doc = canvas1.contentWindow;
      if ( !canvas1doc ) canvas1doc = canvas1.window;
and then inside the SVG you've sent a message from <script> there to alias a function living inside SVG
  parent.AddElement = AddElement;
then you call that function from within the HTML.
Suppose there is no script at all inside the SVG (as served into HTML through an iframe). That's the limitation
that I've currently bounced up against using <iframe> that I don't see using either <object> or <embed>. In either of those cases I just fish for getSVGDocument() (or in the worst case contentDocument -- which seems to be needed with FF for who knows what reason!), but with <iframe> even contentWindow:window doesn't seem to deliver the goods!
if you try to look at the charactistics of canvas1doc following your getting it as either contentWindow or window,
it has no nodeName; no firstChild and its parentNode has no nodeName. The SVG document, once retrieved through script always seems to appear as a document node, with its firstChild being document.documentElement, namely svgRoot.
So I am still unable to modify a scriptless SVG document unless it "wants" to be, through the use of calls to its putative parentNode.
Received on Sunday, 5 April 2009 18:44:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:28:24 UTC