Re: Targeted Cross-Document Scripting

On Feb 11, 2006, at 11:27 PM, Doug Schepers wrote:

>
> For the record, my working example is here:
>   http://svg-whiz.com/svg/instances/
>
> To get this to work, I had to fork my code, and to pass each  
> instance a
> unique identifier from the parent HTML, that was passed back as a  
> parameter.
> I think that's remarkably inelegant, and it did not consistently  
> work for me
> outside the limited confines of this test code.

The following much simpler code works in Safari (with a WebKit  
nightly, that's the only versions with SVG support so far) Opera 9  
and Firefox 1.5:
I don't have Win IE + ASV to test with but I suspect it would work  
there too.

This relies on three things that are not currently standardized:

1) contentWindow property of the <object> and <iframe> elements in HTML
2) frameElement property of the global object
3) parent property of the global object

But I think all three are interoperably implemented in major UAs.

The CDR proposed document.referencingElement would replace the need  
for 2.

referencingElement + contentDocument could replace the need for 1 if  
you attached the functions to the document instead of the global object.

Regards,
Maciej

Received on Sunday, 12 February 2006 11:26:05 UTC