Js/jquery How to get the elements in an iframe child page:
First, use window.frames["iframe ID"] to get the element
function () { varwindow.frames["Oiframe"]. document.getElementById ("GetFrame"); Console.log (oiframe);}
Note: Be sure to add window.onload or domcontentloaded here, that is, after the DOM is loaded or the page is loaded.
Second, using Window.name to get the element
var oidframe = window. oiframe. document.getElementById ("GetFrame"); Console.log (oidframe);
Oiframe is the Name property value of the IFRAME, which does not have to be written in window.onload or domcontentloaded, please test it yourself.
Third, using getElementById to get the element
var document.getElementById ("Oiframe"). Contentwindow. document.getElementById ("GetFrame"); Console.log (oidframe);
After using document.getElementById to get the IFRAME element for this page, get the elements of the IFRAME child page. This method of acquisition does not have to be written in window.onload or domcontentloaded
Iv. using jquery to get
var ojiframe = $ ("#oIframe"). Contents (). Find ("#getFrame"). html (); Console.log (ojiframe);
Js/jquery iframe child page Gets the parent page element method:
First, the use of JS
var fatherele = window.parent.document.getElementById ("title"); Console.log (Fatherele);
Ii. Use of JQ
var fatherelejq = $ ("#title", parent.document); Console.log (FATHERELEJQ);
Parent page:
<DivID= "title">Index contains IFRAME sub-page</Div> <DivID= "Parent"> <iframename= "Oiframe"ID= "Oiframe"src= "iframe.html"frameborder= "0"width= "+"Height= "562"></iframe></Div>
Iframe.html Sub-page:
<id= "GetFrame">iframe</div>
Reference Link: http://java-my-life.iteye.com/blog/1275205
Elements interoperate between parent and child pages (IFrame sub-page)