【问题标题】:How to get previous URL after navigating to another page导航到另一个页面后如何获取上一个 URL
【发布时间】:2019-05-25 20:04:38
【问题描述】:

我在我的页面上实现了previous button,它可以让我返回 到上一页。

Page A -> Page B(有上一个按钮) 如何找到Page A 的链接,以便使用javascript/jQuery 将我带回Page A

我试过这个链接

How to get the previous URL in JavaScript?

我使用了这个history.back(),但它适用于 onclick

如何获取href。

【问题讨论】:

标签: javascript jquery href


【解决方案1】:

使用document.referrer:

console.log(document.referrer);
/* The above logs this page because Stack Snippets are run on stacksnippets.net,
   and therefore your browser went there from this page 
   (because you're running the code here).
*/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-16
    相关资源
    最近更新 更多