PHP:浏览器返回上一页 [英] PHP: Browser go back a page

查看:365
本文介绍了PHP:浏览器返回上一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要这样的东西:

<?php
if($something)
    header('Location:javascript:history.go(-2)');
?>

,但header('Location:javascript:history.go(-2)');不起作用.有其他选择吗?

but header('Location:javascript:history.go(-2)'); doesn't work. Any alternatives?

我不知道用户所在的页面,所以我无法对URL进行硬编码.

I don't know the page the user was just on, so I can't hardcode the url.

推荐答案

从您的角度来看,我认为您可能正在寻找类似的东西:

From your point of view, i think you might be looking for something like this:

<html><head></head><body>
<?php
if($something){
?>
<script type="text/javascript">
window.history.go(-2);
</script>
<?php
}
?>
</body></html>

这篇关于PHP:浏览器返回上一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆