"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"