JS how to determine whether to invoke the IFRAME parent page element and method in the IFRAME/jquery

Source: Internet
Author: User
Mode one if (self.frameelement && self.frameElement.tagName = = "IFRAME") {alert (' in IFRAME ')}//Mode two if (Window.fram Es.length! = parent.frames.length) {alert (' in IFrame ');}//Way three if (self! = top) {alert (' in IFrame ');} first, find parent page element in IFRAME Method: $ (' #id ', window.parent.document) second, get the element method in the IFRAME in the parent page: $ (this). Contents (). Find ("#suggestBox") third, Call the methods and variables defined in the parent page in the IFRAME: Parent.method Parent.value IV, the parent page invokes the JS method within the IFRAME, without having to add an ID to the IFRAME, simply select the IFRAME with JQ to line the $ ("#id"). Find ("iframe") [0].contentwindow.func ()

JS how to determine whether to invoke the IFRAME parent page element and method in the IFRAME/jquery

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.