This time I will bring you JQueryHow to operate the associated page of iframe, what are the precautions for JQuery to operate the associated page of iframe, the following is a practical case, let's take a look.
JQUERY IFRAME
The following simply uses Jquery to operate some records of the iframe. This can be achieved using pure JS.
First, how to find the elements of the parent page in the iframe:
$('#id', window.parent. document )
Second, how to get the elements of the iframe in the parent page:
$(this).contents().find("#suggestBox")
Third, call the method and variable defined in the parent page in the iframe:
parent.method parent.value
Use jquery to get the parent in the iframe Page body
iframe.html
<html> <script src='jquerymin.js'> </script> <body id='1'> <p>it is a iframe</p> </body> <script> $(document).ready( function() { var c = $(window.parent.document.body) //麻烦的方法: var c = $($(window).eq(0)[0].parent.document).find('body'); ,忘了可以用前面的方法了 alert(c.html()); } ); </script> </html>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
Calling the iframe page based on ID (with code)
How does jquery make iframe adaptive to the front-end height
The above is the detailed content of How JQuery operates the associated page of iframe. For more information, please follow other related articles on the PHP Chinese website!