完全可以用window.open()代替window.showModalDialog()的方法

来源:互联网 发布:政府办公软件系统 编辑:程序博客网 时间:2024/04/24 20:13

【转】http://www.javaeye.com/topic/123995

 

有两个页面,一个是调用页面---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);

 

 

 

 

 

 

 

 

open() 不可能代替 showModalDialog()
这样做是钻死胡同牛角尖.
唯一方法:可以通过iframe或DIV在同一个Window实现


http://www.laputac.com/tech/

 

 

 

 

原创粉丝点击