真正的用window.open()代替window.showModalDialog()

模式窗口太过于局限性,所以我研究了一个完全可以用window.open()代替window.showModalDialog()的方法,其资料贴在了下面:

 

有两个页面,一个是调用页面---main.html,一个是被调用页面---modalWindow.html

main.html

--------------------------------------------------------------------------------------------------------------------------------------------

click here


 <script>
  
 newWin=null;
  
function abc()
{
newWin =window.open('modalWindow.html','newWin','height=200,width=400,top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no,status=no');
 
  
}

 

window.onfocus=function (){  

 if(newWin){
  if(!newWin.closed)
   newWin.focus();
  
 } 
 
};

window.document.onfocus=function (){  


 if(newWin){
  if(!newWin.closed)
 newWin.focus();
  
 } 
 
};

 

window.document.onclick=function (){  


 if(newWin){
  if(!newWin.closed)
 newWin.focus();
  
 } 
 
};

window.document.ondblclick=function (){  


 if(newWin){
  if(!newWin.closed)
 newWin.focus();
  
 } 
 
};

</script>

 

----------------------------------------------------------------------------------------------------------------------------------

modalWindow.html

------------------------------------------------------------------------------------------------------------------------------------

sub window!!!!



 

在这个页面modalWindow.html中的方法可以调用父窗口的方法

其用法是 opener.functionName(param);

 

 


你可能感兴趣的:(html,框架,浏览器,IE,企业应用)