The child form in IFRAME calls the method in the parent form

Source: Internet
Author: User
Tags sample html code
IFRAME Syntax:

IFRAME tag -- indicates the HTML inline framework

  • IFRAMETags appear in pairs.<iframe>Start,</iframe>End
  • Attribute
    • name-- Defines the content page name, which is used for linking to the Framework page
    • src-- Defines the content page url
    • Frameborder -- defines the border of the content page. The value is (1 | 0) and the default value is 1.
      • 1-- Display a border between each page
      • 0-- Do Not Display borders
    • marginwidth-- Defines the width of the upper and lower boundary displayed in the HTML file in the framework. The value is PX. The default value is determined by the browser.
    • marginheight-- Defines the width of the Left and Right Border displayed in the HTML file in the framework. The value is PX. The default value is determined by the browser.
    • Scrolling -- defines whether a scroll bar exists. The value is (yes|no|auto). The default value isauto
      • yes-- Display the scroll bar
      • no-- Do not display the scroll bar
      • auto-- Display the scroll bar when necessary
    • align-- Vertical or horizontal alignment
    • height-- Framework height
    • width-- Frame width
  • URL: http://www.dreamdu.com/xhtml/tag_iframe/
Sample HTML code
  1. <IFRAMESrc = "http://www.dreamdu.com/xhtml/" width = "200" Height = "500"> </Iframe>
<iframe src="http://www.dreamdu.com/xhtml/" width="200" height="500"></iframe>

 

Main form: HTML code
  1. <HTML>
  2.  <Head>
  3. <Title>CSI System</Title>
  4.  </Head>
  5. <ScriptLanguage = "JavaScript">
  6. <! --
  7. Function F1 (STR ){
  8. Alert ("hello," + STR + ", I am the JavaScript method of CSI system! ");
  9. }
  10. //-->
  11. </SCRIPT>
  12. <Body>
  13. <IFRAMESrc = "cti.html" width = "250" Height = "200" scrolling = "no" frameborder = "1">
  14. </Iframe>
  15. <H1Id = "myh2">Hello, I'm CSI!</H1>
  16. </Body>
  17. </Html>
<HTML> Subform: HTML code

 
  1. <HTML>
  2.  <Head>
  3. <Title>CTI system</Title>
  4.  </Head>
  5. <ScriptLanguage = "JavaScript">
  6. <! --
  7. Function F2 (s ){
  8. Window. Parent. F1 (s );
  9. }
  10. //-->
  11. </SCRIPT>
  12.  <Body>
  13.  <FormMethod = post action = "">
  14. <InputType = "button" value = "Click me! "Onclick =" f2 ('cti ');">
  15.  </Form>
  16. I am in CTI system!
  17.  </Body>
  18. </Html>
<HTML> <HEAD>  <TITLE> CTI System</TITLE> </HEAD><SCRIPT LANGUAGE="JavaScript"><!--function f2(s) {window.parent.f1(s);}//--></SCRIPT> <BODY> <FORM METHOD=POST ACTION=""><INPUT type="button" value="Click Me!" onclick="f2('CTI');"> </FORM> I am in CTI System! </BODY></HTML>
Effect:

 

Refer:

1. html <IFRAME> tag

2. A small IFRAME problem attracts great consideration

3. IFRAME

4. Javascript changes the IFRAME attribute (address, height, width)

5. Knowledge about js iframe operations

6. How to call the IFRAME parent window and Child Window

7. Access the User-Defined Functions in the parent window in the Child Window

8. DHTML Reference Manual: IFRAME element | IFRAME object

9. IFRAME usage and precautions

10. IFRAME syntax

11. Use IFRAME to embed and pre-load webpages

 

Reference page: http://www.cnblogs.com/waxdoll/articles/271018.html

5.2.6 Javascript

Extends Web pages use JavaScript to perform complex interactions between the user and the page. it is important to know how to execute JavaScript Functions from within Internet Explorer. the simplest method is to use navigate with the prefix javascript: Then the function name. however, this does not give us a return value, nor will it work correctly in all situations.

We shall start with a HTML page, which contains a JavaScript function to display some text. This will be saved as your cript.html

 

HTML code
  1. <HTML>
  2.  <SpanId = "hiddentext" style = "display: none">This was displayed by JavaScript</Span>
  3. <ScriptLanguage = "JavaScript">
  4. Function jsfunction ()
  5. {
  6. Using plain Doc ument. All ["hiddentext"]. style. Display = "Block ";
  7. Return "OK ";
  8. }
  9.  </SCRIPT>
  10. </Html>

 

We can then use the document. invokescript method to execute the Javascript thus:

C #2.0

 

C # code
  1. Private VoidBtnnavigate_click (ObjectSender, system. eventargs E)
  2. {
  3. Navigatetourlsync (@ "C:/javascript.html ");
  4. StringStrretval = "";
  5. Strretval = (String) Webbrowser. Document. invokescript ("jsfunction ");
  6. MessageBox. Show (strretval );
  7. }
private void btnNavigate_Click(object sender, System.EventArgs e){     NavigateToUrlSync(@"C:/javascript.html");     string strRetVal = "";     strRetVal = (string)WebBrowser.Document.InvokeScript("jsFunction");     MessageBox.Show(strRetVal);}

Http://www.javaeye.com/topic/265347

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.