In actual programming, sometimes we need to access the child form in the parent form or access and operate on the child form, or we can access or call the method of the parent form in the child form. The implementation is very simple. See the following example:
"Id =" code_closed_image_105656 "style =" display: none; ">" id = "code_open_image_105656"> code
Parent form (webform1.aspx ):
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> parent form </title>
<SCRIPT type = "text/JavaScript">
VaR sys = function (){};
SYS. sayhello = function (){
Alert ('Hello parent/opner page !! ');
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<IFRAME id = "IFM"> </iframe>
<Input type = "button" onclick = "document. getelementbyid ('ifm '). src = 'webform2. aspx '; // window. open ('webform2. aspx ') "value =" open child "/>
<Input type = "button" onclick = "window. Frames ['ifm']. SYS. sayhello ()" value = "INVOKE child domain"/>
</Form>
</Body>
</Html>
Child form (webform2.aspx ):
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> subform </title>
<SCRIPT type = "text/JavaScript">
VaR sys = function (){};
SYS. sayhello = function (){
Alert ('Hello child page !! ');
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Input type = "button" value = "INVOKE parent/opner domain" onclick = "window. Parent. SYS. sayhello ();"/>
</Form>
</Body>
</Html>