JS Child page Parent page methods and 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 ();//adjust the AA function window.parent.bb;//the BB variable for example: To get the value of a text box with the ID AAA in the Sub-page window.parent.$ ("#aaa"). Val (); The premise of this notation is to refer to the jquery window.parent.getElementById ("AAA"). Value; JS's wording

(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 paging sub-page How  jquery is written//commented: Where IDs of Childframe and Addframe-time IFRAME

  

JS Child page Parent page methods and variables call each other

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.