[Greasemonkey] reading document tree of iframe
James Cowan
cowanj at freenet.co.uk
Wed Aug 9 14:40:08 EDT 2006
the suggestion of using GM_setValue and GM_getValue to communicate the
parent and child iframe works fine. The gm script detects the parent of the
iframe and before the url is loaded sets a global variable and when the new
page is loaded it detects that the variable is set, looks at the dom tree
and switches off the global variable. It is a bit ugly but it works.
James
----- Original Message -----
From: "Aaron Boodman" <zboogs at gmail.com>
To: <greasemonkey at mozdev.org>
Sent: Tuesday, August 08, 2006 7:33 PM
Subject: Re: [Greasemonkey] reading document tree of iframe
> Yeah, Greasemonkey runs in the same reduced permission land that
> regular webpages do, which means that it cannot reach across frames
> from different domains.
>
> You might be able to do what you want akwardly by writing two scripts
> -- one for the iframe domain and one for parent document domain.
>
> I can't think of an obvious way to get them to talk to each other
> short of bouncing it off a server you control, but I have heard about
> this cool hack where you have this structure:
>
> [parent document - domain a
> [iframe - domain b
> [iframe - domain a
>
> In this scenario, I heard that the parent document could reach the
> nested iframe because they are the same domain with a path like:
> window.frames[0].frames[0]. If that's true, then the iframe script
> could create a nested iframe in the right domain, and you could use
> that to communicate between the two scripts.
>
> Yes, this is horrific. Sorry, maybe this is a better project for a
> fully-fledged extension.
>
> - a
>
> On 8/8/06, James Cowan <cowanj at freenet.co.uk> wrote:
>> Hi
>>
>> I am loading a document into an iframe and then want to analyse the dom
>> tree
>> of the loaded document.
>>
>> Using iframe.addEventListener('load', getDomTree, true); I can attach
>> some
>> code to analyse the tree fine when it is from the same domain as the
>> document that contains the iframe. When I load a url into the iframe from
>> a
>> different domain, I do not seem to be able to read it
>> (iframe.contentWindow.document is null).
>>
>> I guess this is probably a general firefox permissions problem rather
>> than a
>> specific greasemonkey query but I was wondering whether anyone knew how
>> to
>> get around this problem.
>>
>> James
>>
>> _______________________________________________
>> Greasemonkey mailing list
>> Greasemonkey at mozdev.org
>> http://mozdev.org/mailman/listinfo/greasemonkey
>>
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
More information about the Greasemonkey
mailing list