超时后自动关闭窗口

时间:2012-10-09 01:31:17

标签: php javascript

我知道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("maxgee@me.com", "$Error Reported on: $errpage", $message);
echo "We have documented the web address of the problem and thank you for helping us    improve our site!"
?>

3 个答案:

答案 0 :(得分:8)

这应该这样做:

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

答案 1 :(得分:0)

如果我正在观看的页面突然关闭,可能看起来有点奇怪。

答案 2 :(得分:0)

这非常简单 - 只需在PHP中编写带有echo的JavaScript代码,就可以将其从自身移出,例如:

<?php

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

?>

一定会奏效。

相关问题