假设有

A.html , B.html

A.html使用js的window.showModalDialog('B.html');

B.html的js里面使用跳转location.href = "http://www.baidu.com";

firefox、chrom 会在弹出框内跳转,IE 会弹出新窗口去显示href的连接

 

解决方法有两种..

1. location.href = "http://www.baidu.com"; 换成

 
  
  1. window.name = "__self"
  2. window.open("http://www.baidu.com" , "__self"); 

2.新建一个页面C.html加入iframe连接B.html,那么就可以随意使用跳转

A.html js部分类容:

 
  
  1. function openWindow(url){ 
  2.         window.showModalDialog(url, null , "dialogWidth=800px;dialogHeight=504px;scroll=0"); 
  3.         location.reload(); 
  4.     } 

C.html内容:

 
  
  1. <body style="width:800px; height:500px;padding:0px ; margin:0px;" > 
  2. <iframe frameborder="0" style="width:800px; height:500px" src="b.html"> 
  3. </iframe> 
  4. </body>