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?
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
$_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
<a href="<?php echo $_SESSION['last_page']; ?>">Back</a>
另外-如果你只是想要一个
<a href="javascript:go(-1)" class="dbutton" onClick="history.back()">Back</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.