Home  >  Article  >  Web Front-end  >  JQueryiframe page operates elements and methods in the parent page (explanation with examples)_jquery

JQueryiframe page operates elements and methods in the parent page (explanation with examples)_jquery

WBOY
WBOYOriginal
2016-05-16 17:14:191112browse

1) How to find the parent page element in an iframe:
$('#id', window.parent.document)

2) Call the methods and variables defined in the parent page in the iframe:
parent.method
parent.value

3) Example

1. Parent page

Copy code The code is as follows:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="IframeDemo._Default" %>









default.aspx


                                                                                >




Copy code

The code is as follows:
<%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="IFrame.aspx.cs" Inherits="IframeDemo.IFrame" %>                                                                                                                                                                                                                                                                 Element
          alert($('#default', window.parent.document).html()); 🎜>                                                                                                                                                                               ;body>


  IFrame.aspx






Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn