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

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
via
  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.
 
ick
David

Received on Sunday, 5 April 2009 18:44:05 UTC