JS in the IFRAME call the parent page implementation code

Source: Internet
Author: User

For example, when you call a () function, you write:

The code is as follows Copy Code

WINDOW.PRAENT.A ();

But I found out that this method is not valid in Chrome browser.


Call this function in the parent page

The code is as follows Copy Code

<script>

function Dey () {

var cards_frame=document.frames ("Card-iframe"); Card-iframe is the name of the IFRAME.
Cards_frame.checkedcard ()//Invoke the method defined in the IFRAME to upload the value of the embedded page to the parent page

}

</script>

2 The method to invoke the parent page definition in the IFRAME

The code is as follows Copy Code

function Alert_window (picurl,h_id)
{
Document.parentWindow.parent.msg (picurl,h_id);
}

MSG () is a function defined by the parent window.

Card-iframe is the id,b () of the IFRAME frame as the Sub page JS function. Contentwindow property is the specified frame or the Window object where the iframe is located, ie can be omitted.

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.