How to find elements in an IFRAME in an IFRAME

Source: Internet
Author: User

Below is the case of an internal iframe looking for external mainFrame var Websitesearchbutton = window.parent.parent.document.getElementById (' MainFrame ')
. ContentWindow.document.getElementById ("Webresource-search-button"); In the IFRAME
1, sub-page to find the elements of the page
$ (window.parent.document). Find (ID);
2. Parent Page---> sub-page
$ (ID). contents (). Find (Element ID). FIND (element ID);
3, sub-page---> Grandfather's page
$ (window.top.document). Find (ID); Example: var body2 = JQuery (Window.top.document.getElementById ("EWebEditor2")). EQ (0). Contents (). Find ("#eWebEditor"). Contents (). Find ("Body"). html ();
Console.log (Body2),  1, Window.top.document.getElementById ("EWebEditor2")     : Indicates that the document in the topmost layer is found in an IFRAME, and then the element in the outermost document is found (the above example represents an IFrame),  2, JQuery (EWebEditor2). Window.top.document.getElementById ("EWebEditor2"))     means to turn eWebEditor2 this iframe into a jquery object  3, JQuery (Window.top.document.getElementById ("EWebEditor2")). EQ (0)    represents the first element taken to  4,. Contents (). Find (" #eWebEditor ")     represents ewebeditor this element in the IFRAME (this element represents an IFRAME again)  5, JQuery (EWebEditor2) Window.top.document.getElementById ("EWebEditor2")). EQ (0). Contents (). Find ("#eWebEditor"). Contents ()      represents ewebeditor content in this iframe  6, JQuery (Window.top.document.getElementById ("EWebEditor2")). EQ (0). Contents (). Find ("#eWebEditor"). Contents (). Find ("Body")    represents the BODY element taken to ewebeditor this content  7, final  jquery ( Window.top.document.getElementById ("EWebEditor2")). EQ (0). Contents (). Find ("#eWebEditor"). Contents (). Find ("Body" ). The HTML ();    represents the contents of the body in the IHow to find elements in an IFRAME in a frame

How to find elements in an IFRAME in an IFRAME

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.