是否有代码可以检测重定向页面或刷新页面(首次加载)之间的差异?

发布于 2024-10-08 22:59:34 字数 103 浏览 0 评论 0原文

如何确定页面是否已刷新 (F5) 或从另一个页面重定向 (responce.redirect)?

我可以使用什么代码在 JavaScript 或 jQuery 中检测到这一点?

How do I determine if the page was refreshed (F5) or redirected from another page (responce.redirect)?

What code could I use to detect that in JavaScript or jQuery?

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

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

发布评论

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

评论(3

静待花开 2024-10-15 22:59:34

您可以检查 Request.ServerVariables["HTTP_REFERER"]; 中的值,我猜它是否刷新或相同的网址应该为 null。

You can check the value in Request.ServerVariables["HTTP_REFERER"]; It should be null I guess if it is refreshed or the same url.

优雅的叶子 2024-10-15 22:59:34

在重定向的情况下,UrlReferrer 将包含上一页的 Url。

http://msdn.microsoft.com/en-us /library/system.web.httprequest.urlreferrer.aspx

在简单刷新中,它将为 NULL。

In case of redirect, UrlReferrer will contain the Url of previous page.

http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx

In a simple refresh, it will be NULL.

感情洁癖 2024-10-15 22:59:34

你不能。 (这就是全部内容,现在让我们将其设为 30 个字符长...)

You can't. (This is all there is to it, now let's make it 30 chars long...)

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