【问题标题】:Logout on tab closed [duplicate]关闭选项卡上的注销[重复]
【发布时间】:2017-12-31 19:09:11
【问题描述】:

我想在关闭应用程序的任何选项卡时触发注销。我试过了 $(window).on('unload', logout);$(window).on('onbeforeunload', logout); 这工作正常,但当我重新加载页面时也会触发事件。如何在重新加载时防止这种情况?在询问之前,我发现了一些选项,例如event.currentTarget.performance.navigation.type,但无法以这种方式分离重新加载和关闭。是否有任何机会仅在标签关闭时触发注销?

【问题讨论】:

  • 什么“上传”?我怀疑有任何可靠的方法可以做到这一点。浏览器没有义务通知服务器用户正在关闭任何东西。
  • f5 或浏览器上传按钮
  • 重新加载,然后呢?
  • 是的,重新加载时。

标签: javascript jquery


【解决方案1】:

根据此处Is there a way in javascript to detect if the unload event is caused via a refresh, the back button, or closing the browser?,无法检测到差异。即使可以,在其他情况下也行不通。

【讨论】:

    猜你喜欢
    • 2013-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多