How does Jsifame interact with functions in the parent window?

Source: Internet
Author: User
Page A contains an iframeSyntaxHighlighter. all (); info & nbsp; | & nbsp; Security & nbsp; | & nbsp;

Page A contains an iframe. Some html code is as follows:

[Html]
& Nbsp; <br/> the js script section on page A is as follows: </p> <p> www.2cto.com <br/> [javascript] <br/> var System ={& nbsp; & nbsp; <br/> & nbsp; CloseFrame: function () {& nbsp; <br/> & nbsp; & nbsp; try {& nbsp; <br/> & nbsp; & nbsp; var frames = document. getElementById ("ifmApp"); & nbsp; <br/> & nbsp; & Nbsp; & nbsp; var AppHelper = frames. contentWindow. appHelper; & nbsp; <br/> & nbsp; & nbsp; if (AppHelper! = Null & typeof (AppHelper) = "object" & typeof (AppHelper. closeQuery) = "function") {& nbsp; & nbsp; <br/> & nbsp; & nbsp; & nbsp; if (! AppHelper. closeQuery () return; & nbsp; <br/> & nbsp; & nbsp; & nbsp ;}& nbsp; <br/> & nbsp; & nbsp;} catch (e) {& nbsp; & nbsp; <br/> & nbsp; & nbsp; & nbsp ;}& nbsp ;& Nbsp; & nbsp; <br/> & nbsp; System. close (); & nbsp; <br/> & nbsp; & nbsp ;},& nbsp; <br/> & nbsp; Close: function () {& nbsp; <br/> & nbsp; document. body. removeChild (ifrm); & nbsp; <br/> & nbsp; & nbsp ;}& nbsp; & nbsp; <br/> }; & nbsp; </p> <p> B. asp page with js functions: </p> <p> [javascript] <br/> var Apphelper ={& nbsp; <br/> & n Bsp; & nbsp; CloseQuery: function () {& nbsp; <br/> & nbsp; & nbsp; if (val = "1") return true; & nbsp; <br/> & nbsp; & nbsp; return false; & nbsp; <br/> & nbsp; & nbsp ;}, & nbsp; <br/> & nbsp; close: function () {& nbsp; & nbsp; <br/> & nbsp; if (parent! = Null & typeof (parent) = "object") {& nbsp; & nbsp; <br/> & nbsp; & nbsp; var System = parent. system; & nbsp; <br/> & nbsp; & nbsp; if (System! = Null & typeof (System) = "object") {& nbsp; <br/> & nbsp; & nbsp; if (System. close! = Null & typeof (System. close) = "function") {& nbsp; <br/> & nbsp; & nbsp; & nbsp; System. close (); & nbsp; <br/> & nbsp; & nbsp; & nbsp; return; & nbsp; <br/> & nbsp; & nbs P; & nbsp; & nbsp; & nbsp ;}& nbsp; <br/> & nbsp; & nbsp; & nbsp ;}& nbsp; <br/> & nbsp; & nbsp; & nbsp ;}& nbsp; <br/> & nbsp; & nbsp; & nbsp ;}& nbsp; & nbsp; <br/>}; & nbsp; </p> <p> parent page, by calling your System. closeFrame to call the function Apph in ifrme Elper. in CloseQuery <br/> Ifame, you can call your Apphelper. close function to call System in the parent window. close </p> <p> Of course, there is A premise to implement such A simple call, that is, A and B need the same domain. <Br/> from the pure land of the soul </p>

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.