简体   繁体   English

如何创建后退按钮,将您带回到您来自的页面?

[英]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.

相关问题 动态后退按钮可导航回您来自的模式 - Dynamic back button to navigate back to modal you came from 检测页面的方法来自后退按钮 - Method to detect page came from back button 当用户在React中单击窗口上的后退按钮时,将道具传递给您来自的组件 - Pass props to the component you came from when user clicks back button on window, in React 当点击“后退”按钮时,你可以停止重新加载前一页吗? - Can you stop a prior page from reloading when “back” button is clicked? 如何创建后退/前进按钮? - How can I create a back/forward button? 从重定向页面退回时如何更新网页? - How to update webpage when you back from the redirected page? 填写联系表后,如何将用户返回到他们来自的页面? - How do I return a user back to the page they came from after filling out a contact form? 如何将从Promise中获得的数据存储到具有相同密钥的对象中? - How can I store the data I get from a Promise back into an object with the same key it came from? 如何处理jQuery中的后退按钮? - How do you handle the back button in jQuery? 一旦到达页面底部,如何禁用滚动备份网页? - How can you disable scrolling back up a webpage once you've reached the bottom of the page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM