【解決】showModalDialog模態窗口,使用JS跳轉連接,IE彈出新窗口

假設有

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> 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章