2012-10-09 83 views
1

我知道PHP是服務器端,但有沒有辦法讓這個窗口關閉3秒後?超時後自動關閉窗口

<link rel="stylesheet" type="text/css" href="style1.css" /> 
<?php 
$contact_message=$_POST['message']; 
$errpage = $_POST['frompage']; 
$ip=$_SERVER['REMOTE_ADDR']; 
$message = "$contact_message -SENT FROM THIS IP: $ip"; 
mail("[email protected]", "$Error Reported on: $errpage", $message); 
echo "We have documented the web address of the problem and thank you for helping us improve our site!" 
?> 
+1

如果有的話,你會看着JavaScript來試圖達到你想要的。 – anditpainsme

+0

@anditpainsme你知道一個腳本可以做到嗎? –

回答

8

這應做到:

<script type="text/javascript">setTimeout("window.close();", 3000);</script> 
+0

非常感謝。 –

+3

請不要鼓勵在setTimeout中使用字符串。 – 2012-10-09 01:49:34

+1

不夠公平,@pst。 'setTimeout(function(){window.close();},3000);'是更好的編碼風格。 –

0

,它可能似乎有點不可思議,如果我看着突然一個頁面被關閉。

+1

它將在彈出窗口中使用,並在提交表單後關閉 –

0

這是非常簡單 - 只要用PHP編寫的JavaScript代碼回聲在你想從自己搬出去,如地方:

<?php 

    echo '<script> window.setTimeout("window.close()", 1000); </script>'; 

?> 

它肯定會工作。