JavaScript 相当于点击浏览器刷新按钮

发布于 2024-10-04 03:45:10 字数 569 浏览 0 评论 0原文

我正在向旧版 Web 应用程序添加功能,以便在某些情况下我们将注销用户,将他们返回到与我们的应用程序分开的登录页面。

该应用程序部分是经典 ASP,部分是 ASP.NET,并使用外部公司范围的身份验证机制。

我们可以通过清除浏览器中的会话cookie并点击浏览器刷新按钮来达到预期的效果(实验性地)。底层身份验证机制将用户重定向到登录页面,当他们输入凭据时,他们会被引导回原来所在的页面。

我们目前正在使用以下方法...

function logoffUser() {
    $.cookie("ASP.NET_SessionId", null);
    $.cookie("ASPSESSIONKEY", null);
    $.cookie("CompanyFormsAuth", null);
    window.location.reload(true);
}

只要用户弹回到外部登录页面,这种方法就有效。但是,浏览器地址栏中显示的地址不会更新,当他们登录时,他们最终会出现在我们应用程序的主页上。

所以根本问题是:是否有一个 JavaScript 相当于点击浏览器刷新按钮?

I am adding functionality to a legacy web application such that in certain circumstances we will log the user off, returning them to a logon page that is separate to our application.

The application is part classic ASP, part ASP.NET and uses an external company-wide authentication mechanism.

We can achieve the desired effect (experimentally) by clearing session cookies in the browser and hitting the browser refresh button. The underlying authentication mechanism redirects the user to the logon page and when they enter their credentials they get directed back to the page they were originally on.

We are currently using the following approach...

function logoffUser() {
    $.cookie("ASP.NET_SessionId", null);
    $.cookie("ASPSESSIONKEY", null);
    $.cookie("CompanyFormsAuth", null);
    window.location.reload(true);
}

This works, insofar as the user gets bounced back to the external logon page. However the address shown in the browser address bar does not get updated, and when they logon they end up on our application's home page.

So the fundamental question is: Is there a JavaScript equivalent to hitting the browser refresh button?

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

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

发布评论

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

评论(1

如果没有你 2024-10-11 03:45:10

这将“刷新”当前页面

window.location = window.location;

This will "refresh" the current page

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