1) Include the domain of the iframe in the scripts includes
2) the script will now run once for the normal window and again for the
iframe content.  You will need to detect which domain the script is running
in, and action accordingly.

You can exchange data between the two running instances of your script, by
either using
a) GM_set and GM_get, or
b) messaging.

Das Shrubber

On Tue, Jul 27, 2010 at 7:59 AM, Tim <[email protected]> wrote:

> Hi there,
>
> I've written a greasemonkey script that creates an 'iframe', and sets
> it source to a different domain of the original webpage. This works
> fine.
>
> How do I access elements in this iframe? Specifically how do I
> use .getElementById("")?
>
> The actual element itself is defined (in a XPCNativeWrapper) and
> its .body etc, but I cannot use .getElementById or tagName.
>
>
> I've tried:
> var frameDoc =
> document.wrappedJSObject.getElementById("frameID").contentDocument;
> GM_log( frameDoc.getElementById("idname") );
>
> And without the wrappedJSObject. Both cases return 'null' or
> 'undefined'.
>
> I've tried setting timeout manually with: window.setTimeout(test,
> 3000);
> Where test was a function holding the above.
>
> And I've tried a timer with
> frameDoc.addEventListener("DOMFrameContentLoaded", test, false);
>
> With the timers I got errors either: "Security Manager vetoed
> action...." if used without unwrapping first with wrappedJSObject, or
> "permission denied.... site xyz to load html.document from site 123".
>
> Any help would be greatly appreciated!
>
> I may consider using GM_XmlHttpRequest instead, however this would not
> work on chrome.
>
> --
> You received this message because you are subscribed to the Google Groups
> "greasemonkey-users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<greasemonkey-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/greasemonkey-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to