The parent page is displayed.

Source: Internet
Author: User
Jquery obtains the data in the <IFRAME> reference subpage on the parent page.
   

<SCRIPT src = "jquery-1.3.1.js" type = "text/JavaScript"> </SCRIPT>

<SCRIPT type = "text/JavaScript">

// Search for all child nodes (including text nodes) within the matching element. If the element is an IFRAME, search for the document content.

// Obtain the element in the <IFRAME> reference subpage.

$ (Document). Ready (function (){

// BTN is the button element in the parent page

$ ("# BTN"). Click (function (){

// Form1 is the form Element in the Child page

Alert ($ ("# iframe1"). Contents (). Find ("# form1" ).html ());

});

});

 

// Call the button on the parent page to call the button method on the Child page

$ (Document). Ready (function (){

// BTN parent page button

$ ("# BTN"). Click (function (){

// Btnsave is the subpage button referenced by <IFRAME>

$ ("# Iframe1"). Contents (). Find ("# btnsave"). Click ();

});

});

 

// Obtain the value of an element on the Child page

$ (Document). Ready (function (){

$ ("# BTN"). Click (function (){

// Select: eq (0) to obtain the value of the first select drop-down list

VaR TXT = $ ("# iframe1 "). CONTENTS (). find ("# form1 Div select: eq (0 )"). find ("option: Selected "). text ();

Alert (txt );

});

});

</SCRIPT>

 

IFRAME is often used in web development, and elements that need to be used in the IFRAME in the parent window or in the IFRAME framework

JS

Obtain the elements in IFRAME in the parent window.

1,

Format: window. Frames ["iframe name value" 2.16.doc ument. getelementbyidx_x ("Control ID in IFRAME"). Click ();

Example: window. Frames ["IFM" mirror.doc ument. getelementbyidx_x ("btnok"). Click ();

2,

Format:

VaR OBJ = Document. getelementbyidx_x ("iframe name"). contentWindow;

VaR ifmobj1_obj.doc ument. getelementbyidx_x ("Control ID in IFRAME ");

Ifmobj. Click ();

Instance:

VaR OBJ = Document. getelementbyidx_x ("IFM"). contentWindow;

VaR ifmobj1_obj.doc ument. getelementbyidx_x ("btnok ");

Ifmobj. Click ();

Get the elements of the parent window in IFRAME

Format: Required parameter parent.doc ument. getelementbyidx_x ("parent window element ID"). Click ();

Example: Response response parent.doc ument. getelementbyidx_x ("btnok"). Click ();

Jquery

Obtain the elements in IFRAME in the parent window.

1,

Format: $ ("# iframe id"). Contents (). Find ("# Control ID in IFRAME"). Click (); // jquery method 1

Example: $ ("# IFM"). Contents (). Find ("# btnok"). Click (); // jquery method 1

2,

Format: $ ("# Control ID in IFRAME", document. Frames ("frame name" ).doc ument). Click (); // jquery method 2

Example: $ ("# btnok", document. Frames ("IFM" example .doc ument). Click (); // jquery method 2

Get the elements of the parent window in IFRAME

Format: $ ('# element ID in the parent window', parent.doc ument). Click ();

Instance: $ ('# btnok', parent.doc ument). Click ();

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.