JS Child page Parent page method variables call each other

Source: Internet
Author: User

(1) The method or variable that the child page calls the parent page:

Window.parent. Method () or variable name
Window.parent is equivalent to locating the parent page and writing code in the parent page.

Window.parent.aa (); // The window.parent.bb of AA function is adjusted ; // Pick BB Variable For example, to get the value window.parent.$ ("#aaa") of the text box with ID AAA in the Sub-page. Val (); //  window.parent.getElementById (//JS notation

(2) parent page Fetch sub-page

Mainly through Contentwindow to the sub-page

document.getElementById ("Childframe"). Contentwindow.childtest (); // Childtest method in the paging sub-page   js notation var childwindow = $ ("#addFrame") [0].contentwindow; // gets the object in the subform childwindow.formsubmit (); // Formsubmit method for fetching sub-pages how  jquery is written // commented: Where Childframe and Addframe are the IDs of the IFRAME

JS Child page Parent page method variables call each other

Related Article

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.