假設有
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"; 換成
- window.name = "__self";
- window.open("http://www.baidu.com" , "__self");
2.新建一個頁面C.html加入iframe連接B.html,那麼就可以隨意使用跳轉
A.html js部分類容:
- function openWindow(url){
- window.showModalDialog(url, null , "dialogWidth=800px;dialogHeight=504px;scroll=0");
- location.reload();
- }
C.html內容:
- <body style="width:800px; height:500px;padding:0px ; margin:0px;" >
- <iframe frameborder="0" style="width:800px; height:500px" src="b.html">
- </iframe>
- </body>