简体   繁体   English

当您单击链接时转到上一个网页

[英]Go to the Previous Webpage When You Click a Link

I have a website, written in PHP, html and javascript. 我有一个网站,用PHP,html和javascript编写。

The base of my problem is I need a 'back' link on a webpage to take you to the page you last came from, as you can get to the webpage through different pages. 我的问题的基础是,我需要网页上的“后退”链接以将您带到最后一个来源的页面,因为您可以通过不同的页面访问该网页。

Below is a scenario that should help explain. 下面是一个应该有助于解释的方案。

There are different sectors, for example: 有不同的部门,例如:

Hospital Courses Ambulance Courses 医院课程救护课程

And different courses, for example: 和不同的课程,例如:

Course 1 Course 2 课程1课程2

There is a link for Course 1 from both the Hospital Courses page and the Ambulance Courses page, which takes you to the Course 1 Page. “医院课程”页面和“救护车课程”页面都有课程1的链接,可将您带到课程1页面。

The Course 1 page has a link, which will say Back. “课程1”页面上有一个链接,该链接将显示“上一步”。

If you came from Hospital Courses, I need the link to take you back there, and if you came from the Ambulance Courses, you need to be taken back to that page. 如果您来自医院课程,我需要链接才能带您回到那里,如果您来自救护课程,则需要回到该页面。

Does anyone know if you can do this, and how to go about doing it? 有谁知道您是否可以这样做,以及如何去做?

The link is: 链接是:

<a href="javascript:history.back()">text</a>

or 要么

<a href="javascript:history.go(-1)">text</a>

(I see that a fair bit, I don't know if history.back() is newer or what...) (我知道,我不知道history.back()是较新的还是什么...)

More on MDN. 有关MDN的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 返回带有动态内容的上一个网页 - go back to previous webpage with dynamic content 只允许通过链接点击查看网页 - Only allow webpage to be viewed via link click 单击按钮时,网页源中的链接是否可能不可见/隐藏? - Is it possible to have a link invisible/hidden in webpage source but active when button click? 单击上一个/下一个按钮wordpress时显示相同类别的帖子 - show post from the same category when you click previous/next button wordpress laravel 6 登录 go 到以前的 url 时不起作用 - laravel 6 when login go to previous url not working 我可以在iFrame中加载域吗?单击链接后,该域会在父窗口中打开,而不是在iframe中打开吗? - Can I load a domain in my iFrame and when you click a link, it opens in the parent window, not the iframe? 单击时的Wordpress文本链接返回“您没有足够的权限访问此页面”。 - Wordpress text link when click returns “you do not have sufficient permissions to access this page.” 单击时从链接打开一个新的弹出窗口 - open a new pop-up window from a link when you click 如何在不单击链接的情况下将 go 直接映射到地图(单击“显示我的位置”按钮后将 go 直接映射到地图)? - How to go direct to maps without click the link (direct go to maps after click the button "show my location")? 点击链接时打开灯箱 - Open lightbox when click on link
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM