Parent Window Controls child window popup and close "Jsdemo"

Source: Internet
Author: User

"Feature description"
Use the window.open () method to achieve the effect of clicking the close of the parent window in any area of the control sub-window open

"HTML code description"

<div class= "box" id= "box" > click on any area, sub window opens </div>

"CSS Code description"

/* Set the box height to match the page height */ body{     0;} html,body{    100%;}. box{
border:1px solid black; 99%; Font-size:50px; line-height:60px; margin:0 auto;}

"JS Code description"

varOBox = document.getElementById (' box ');d Ocument.onclick=function(){    if(!window.obj1) {obj1= window.open ("http://baidu.com", "_blank", "height=400,width=400,top=10,left=10"); Obox.innerhtml= "Click on any area, sub-window close"; }Else{        //the newly created Window object has a opener property that holds the original window object that opened it. Console.log (Obj1.opener = =window)//close the newly opened windowObj1.close (); //Delete Obj1 Property        Deletewindow.obj1; Obox.innerhtml= "Click on any area, child window pops up"; }} 

"Effect Show"

"Source View"

Parent Window Controls child window popup and close "Jsdemo"

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.