[Greasemonkey] Accessing content in a sub frame

Charles Iliya Krempeaux supercanadian at gmail.com
Tue May 23 15:54:33 EDT 2006


Hello Terry,

On 5/23/06, Terry Brooks <tabrooks at u.washington.edu> wrote:
>
>
> I am trying to write a Greasemonkey script for a frameset page and would
> like to access the content in a subframe.  I'm having trouble
> constructing an XPath that will take me from the frameset page down into
> the subframe page.  The XPath into the frameset page is:
> /html/frameset/frameset/frame[1] and the XPath into the subframe is:
> /html/body/p[1]/a[1].  How does one stitch these two together so I can
> write a single XPath from the frameset page right down into the subframe
> page?
>

I don't think you can access the content of a sub-frame with an XPath like
that.

You probably have to use something like....

var iframe_element = document.getElementById("the-id-of-the-iframe");

var iframe_document = iframe_element.contentWindow.document;

And then once you have the "document" of that iframe then you can apply you
XPath's to that.


See ya

-- 
    Charles Iliya Krempeaux, B.Sc.

    charles @ reptile.ca
    supercanadian @ gmail.com

    developer weblog: http://ChangeLog.ca/
___________________________________________________________________________
 Make Television                                http://maketelevision.com/


More information about the Greasemonkey mailing list