如何在不使用document.referrer的情况下将父级URL获取在JS中

发布于 2025-01-29 18:21:06 字数 81 浏览 2 评论 0原文

我需要使用JS重定向到当前页面的父级URL,我可以找到文档。省略了,或者具有意外的格式。

我问,还有其他方法可以实现这一目标吗?谢谢!

I need to get the parent url which redirect to current page using JS, I find document.referrer can achieve, but our company has some security rules said can't trust that the referrer header is safe - it can be spoofed, omitted, or have an unexpected format.

I am asking are there any other way to achieve this? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉鱼一梦 2025-02-05 18:21:06

我知道的另一种方式是看窗口对象

window.location.origin

The other way I know of is looking into the window object

window.location.origin
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文