A small example of operations between parent and child windows

Source: Internet
Author: User
1 The operation between the child parent window opened with window. openr is different from that of the framework. The child window and the parent window are associated with opener. The source window needs to access the subwindow through its handle. The following small example is intended to help new users better understand their operations.
2
3 Test.htm
4
5 < Html >
6 < Head >
7 < Meta HTTP - Equiv = " Content-Type " Content = " Text/html; charset = gb2312 " >
8 < Meta name = " Generator " Content = " Microsoft Front Page 4.0 " >
9 < Meta name = " Progid " Content = " FrontPage. Editor. Document " >
10 < Title > Actions on the Child parent window </ Title >
11 </ Head >
12 < Body >
13 < Script >
14 VaR Win = Null ;
15 Function OP (){
16 Win = Window. Open ( " About: blank " , " Win " , " Width = 200, Height = 200 " );
17 Win.doc ument. Write ( " <Input type = 'button 'value = 'close parent window 'onclick = 'window. opener. Opener = NULL; window. opener. Close ()'> " );
18 Win.doc ument. Write ( " <Input type = 'button 'value = 'refresh your window 'onclick = 'window. opener. Location. Reload ()'> " );
19 }
20 </ Script >
21 < Input onclick = " OP () " Value = " Open Window " Type = " Button " > < Input type = " Button " Value = " Minimize " Onclick = " If (WIN & Win. Open &&! Win. Closed) {win. resizeTo (0, 0); win. moveTo (0, window. Screen. width);} else alert ('window not opened or closed ') " > < Input type = " Button " Value = " Maximize " Onclick = " If (WIN & Win. Open &&! Win. closed) {win. moveTo (-4,-4); win. resizeTo (screen. availwidth + 8, screen. availheight + 8);} else alert ('No window opened or closed '); " > < Input type = Button Value = " Close subwindow " Onclick = " If (WIN & Win. Open &&! Win. Closed) {win. Opener = NULL; win. Close ()} else alert ('window not opened or closed ') " > < Input type = Button Value = " Refresh subwindow " Onclick = " If (WIN & Win. Open &&! Win. Closed) {win. Location. Reload (); win. Focus ()} else alert ('window not opened or closed ') " > < Input type = " Button " Value = " View the size of the subwindow " Onclick = " If (WIN & Win. Open &&! Win.closedw.alert(win.doc ument. Body. clientwidth + '* 'win.doc ument. Body. clientheight); win. Focus () ;}else {alert ('window not opened or closed ')}; " >
22 </ Body >
23 </ Html >
24
25

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.