简体   繁体   English

如何防止用户在多个浏览器选项卡中打开应用程序?

[英]How to prevent user from opening the application in multiple browser tabs?

We are looking for a way to prevent users from opening the application in multiple tabs under the same browser.我们正在寻找一种方法来防止用户在同一浏览器下的多个选项卡中打开应用程序。

The idea is to get plugged into one of the query Filter and then get access to the session maybe, and check if there is an already opened tab before proceeding.这个想法是插入其中一个查询过滤器,然后访问 session 可能,并在继续之前检查是否有已打开的选项卡。

I looked into httpSession and HttpRequest stuff but found nothing that can help.我查看了httpSessionHttpRequest的东西,但没有发现任何帮助。

Is there any functionality in the java side to know if the app is already opened in another tab? java 端是否有任何功能可以知道该应用程序是否已在另一个选项卡中打开?

thanks,谢谢,

There's ways to accomplish this with Javascript.使用 Javascript 可以实现此目的。

See past questions / answers查看过去的问题/答案

But all of those javascript techniques fail to work if...但是,如果...

  • your user simply turns off Javascript.您的用户只需关闭 Javascript。
  • they load the website from multiple browsers.他们从多个浏览器加载网站。
  • they load the website from normal and incognito modes on the same browser.他们在同一浏览器上以正常模式和隐身模式加载网站。
  • they load the website from multiple devices (laptop and cell phone).他们从多种设备(笔记本电脑和手机)加载网站。

You'll wind up with a mix of feature to attempt to prevent this (but it's a losing battle, and there's countless ways to get around it).您最终会使用多种功能来尝试防止这种情况发生(但这是一场失败的战斗,并且有无数种方法可以绕过它)。

If you have a login, you'll want to track past logins and offer to disconnect / invalidate those other logins on a new login.如果您有登录名,您将需要跟踪过去的登录名并提供在新登录名时断开/使其他登录名无效。 (this will help with the multiple browsers and devices attempts). (这将有助于多个浏览器和设备的尝试)。 Your authorization layer on your server side will invalidate old sessions if they are attempted to be used.如果尝试使用旧会话,则服务器端的授权层将使旧会话无效。

If you have multiple tabs in the same browser, the javascript techniques from the old questions/answers are probably the best.如果您在同一个浏览器中有多个选项卡,那么旧问题/答案中的 javascript 技术可能是最好的。

There are also people attempting to use websocket to act as the single point of communication, but I don't understand how that could work, but you'll come across it in your research.也有人试图使用 websocket 作为单点通信,但我不明白它是如何工作的,但你会在研究中遇到它。

From the server's perspective, it doesn't matter if the requests come from the same browser tab, different tabs, different browsers or different devices.从服务器的角度来看,请求来自相同的浏览器选项卡、不同的选项卡、不同的浏览器或不同的设备都没有关系。 Two tabs can share the same session.两个选项卡可以共享同一个 session。 There is no way for the server (or the servlet) to know whether the request came from tab A or tab B. Tabs are a browser feature, it doesn't get sent in the HTTP header.服务器(或 servlet)无法知道请求是来自选项卡 A 还是选项卡 B。选项卡是浏览器功能,它不会在 HTTP header 中发送。

If you would elaborate on why you want to do this, I might be able to give a better answer.如果您详细说明为什么要这样做,我可能会给出更好的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 防止在多个浏览器选项卡上打开 html 文件 - prevent opening an html file on multiple browser tabs 在执行任务时如何限制用户在浏览器中打开多个选项卡? - How to restrict user in opening multiple Tabs in a browser while performing tasks? 如何阻止自定义书签打开多个浏览器选项卡 - How to stop a custom bookmarklet from opening multiple browser tabs 如何防止 iframe 打开新标签? - How to prevent an iframe from opening new tabs? 您如何检测并防止用户使用php / javascript从多个浏览器选项卡访问Web应用程序? - How do you detect and prevent a user from accessing a web app from multiple browser tabs using php/javascript? 在浏览器的特定窗口中打开多个标签? - Opening multiple tabs in specific window of browser? 如何防止用户拥有同一个 Web 应用程序的多个实例 - How to prevent a user from having multiple instances of the Same Web application 如何拒绝/阻止用户在浏览器的新选项卡中打开我网站中的链接? - How do I deny/prevent users opening links in my site in new tabs on their browser? 如何防止mailto事件在浏览器中打开新选项卡 - How to prevent mailto event from opening a new tab in browser html - 如何防止浏览器打开href中指定的链接? - html - How to prevent the browser from opening the link specified in href?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM