2012-07-14 116 views
1

代碼有問題,不再工作了,但它沒有重新打開新窗口.....正在使用以下代碼自動關閉當前窗口並打開新窗口帶有新網址的窗口。請看看代碼有什麼問題。自動關閉當前窗口,並用新的URL地址打開新窗口

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="prahma" content="no-cache"> 
<title>Auto Close and Open New window</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 

<script language="javascript"> 
var url = "http://www.myweb.com/weather_control.php?"+Math.random() 
window.open(url,"",""); 
window.open('', '_self', ''); 
window.close(); 
</script> 

</head> 
<body onload="closeIt();"> 
</body> 
</html> 

此代碼適用於自動關閉當前網址並在var中打開指定網址的新窗口。但您需要接受「允許總是彈出此網站」。

感謝

+0

我認爲你需要告訴我們** **什麼是錯了,第一......到底是什麼不工作?任何錯誤?它無法使用的特定瀏覽器? – Lix 2012-07-14 22:15:20

+0

也有沒有關係在您的文章中的PHP ...請刪除該標籤... – Lix 2012-07-14 22:16:11

+0

其關閉,但不打開「var url =」weather_control.php?「+ Math.random()」在新窗口中。 – 2012-07-14 22:16:20

回答

0

你知道,http://www.myweb.com/weather_control.php是死的頁面,對不對? 嘗試使用此:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="prahma" content="no-cache"> 
<title>Auto Close and Open New window</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 

<script language="javascript"> 
    var url = "http://www.myweb.com/weather_control.php?"+Math.random() 
    window.open(url,"","MyTitle"); 
    window.open('', '_self', ''); 
</script> 

</head> 
<body onload="setTimeout(function(){window.close();},2000)"> 
</body> 
</html> 
0

試試這個

<html> 
 
<head> 
 
    <script> 
 
\t 
 
\t function gio() 
 
     { 
 
      popup = window.open('http://www.wholewordz.cf/2017/02/kenya-says-it-will-shut-worlds-biggest.html');   
 
      setTimeout(5000); 
 
     } 
 
     
 

 
\t 
 
function closed(){ 
 
    
 
setTimeout("window.close()", 500); 
 
} 
 
     function call() 
 
     { 
 
      popup = window.open('http://www.google.co.in');   
 
      setTimeout(wait, 8000); 
 
     } 
 
     function caller() 
 
     { 
 
      setInterval(call, 12000); 
 
     } 
 
     function wait() 
 
     { 
 
      popup.close(); 
 
closed(); 
 
     } 
 
\t \t 
 

 
     
 
    
 
\t \t 
 
\t \t 
 
    </script> 
 
</head> 
 
<body onload="caller(); gio();"> 
 
</body> 
 
</html> 
 
<html>