[英]How can I create a back button that takes you back to the page you came from?
I am trying to create a button that knows what page you came from and enters that value into the anchor tag. 我试图创建一个按钮,该按钮知道您来自哪个页面,并将该值输入到定位标记中。 Does anyone know a solution using either jQuery or PHP or both?
有谁知道使用jQuery或PHP或同时使用这两者的解决方案?
problem with 问题
<a href="javascript:go(-1)">back</a>
? ?
<FORM>
<INPUT TYPE="button" VALUE="Go Back" onClick="history.back()">
</FORM>
Also you can go back more pages, like this: 您也可以返回更多页面,例如:
<FORM> <INPUT TYPE="button" VALUE="Go Back" onClick="history.go(-1)"> </FORM>
In PHP, you could keep track of the last page the user was on by using 在PHP中,您可以通过使用跟踪用户访问的最后一页
$_SERVER['REQUEST_URI'];
and storing it in the session. 并将其存储在会话中。
$_SESSION['last_page'] = $_SERVER['REQUEST_URI'];
and run it after your html for the current page is rendered, then in a link you could have something like this 并在呈现当前页面的html之后运行它,然后在链接中可能会有类似的内容
<a href="<?php echo $_SESSION['last_page']; ?>">Back</a>
另外-如果你只是想要一个
<a href="javascript:go(-1)" class="dbutton" onClick="history.back()">Back</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.