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