[英]how to redirect back to before page
i found this link Redirect with Timer in PHP? 我发现此链接在PHP中与Timer重定向?
i already try this 我已经尝试过了
<meta http-equiv="refresh" content="5;url=http://yourdomain.com"/>
<?php
// wait 5 seconds and redirect :)
echo "<meta http-equiv=\"refresh\" content=\"5;url=http://yourdomain.com\"/>";
?>
Its work but i want redirect back to previous page, any idea? 它的工作,但我想重定向回到上一页,有什么想法吗? the algorithm is i change page after 5 seconds and want back at previous page after 5 sec to and continue back.. sorry for my bad english
算法是我在5秒后更改页面,并希望在5秒后返回上一页并继续返回..对不起,我的英语不好
Use HTTP_REFERER which will give you the page from where you came to the current page. 使用HTTP_REFERER,它将为您提供到当前页面的页面。
$_SERVER['HTTP_REFERER']
ref: http://php.net/manual/en/reserved.variables.server.php 参考: http : //php.net/manual/en/reserved.variables.server.php
<?php
// wait 5 seconds and redirect :)
echo "<meta http-equiv=\"refresh\" content=\"5;url=".$_SERVER['HTTP_REFERER']."\"/>";
?>
use window.go(-1);
使用
window.go(-1);
for details help see http://www.w3schools.com/jsref/met_his_go.asp 有关详细信息,请参见http://www.w3schools.com/jsref/met_his_go.asp
Can Be done with Pure javascript 可以用纯JavaScript完成
setTimeout(function(){
window.history.back()
}, 5000);
OR if you want to use php 或者,如果您想使用php
setTimeout(function(){
window.location = '<?=$_SERVER['HTTP_REFERER'] ?>'
}, 5000);
You could try redirecting to 您可以尝试重定向到
sleep(5);
$_SERVER['HTTP_REFERER']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.