简体   繁体   English

我如何知道我的网站不在同一浏览器的另一个选项卡上运行?

[英]How Do I know my site is not running on another tab in a same browser?

How Do I know my site is not running on another tab in a same browser? 我如何知道我的网站不在同一浏览器的另一个选项卡上运行? Any function or script exist which is give me how many tab has running my site in a same browser? 是否存在任何功能或脚本,这些功能或脚本可以让我在同一浏览器中运行多少个选项卡?

  1. Page loads 页面加载
    • Store a value in a cookie 将值存储在Cookie中
  2. Page unloads 页面卸载
    • Remove cookie 删除cookie

If at step 1. the cookie already exists then do what you need to do ;) 如果在步骤1. cookie已经存在,则执行您需要做的事情;)

Very basic and naive solution! 非常基本和天真的解决方案!

I think there is a way to do cross tab communication, but I can't remember what it's called... or maybe i'm dreaming. 我认为有一种方法可以进行跨选项卡通信,但是我不记得它的名字了……或者我在做梦。

Edit: The localStorage change event might also be of help 编辑: localStorage更改事件也可能有帮助

You could check is a session variable is set? 您可以检查是否设置了会话变量? this should pick up in the same browser different tab 这应该在同一浏览器的不同标签中显示

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

相关问题 如何检查用户是在一个选项卡上登录该站点而不是在同一浏览器中的另一个选项卡上? - How can you check if a user is logged into the site on one tab but not on another tab from the same browser? 如何知道哪个站点正在运行我的模块? - How to know which site are running my module? 我如何知道我的代码是否作为 React Native 运行 - How do I know if my code is running as React Native 在同一浏览器上对另一个标签进行任何更改时,如何刷新标签数据 - How to refresh tab data when I m making any changes to another tab on same browser 运行 gulp 后如何在浏览器选项卡中打开站点? - How to open the site in a browser tab after running gulp? 我怎么知道用户关闭html标签或浏览器? - How can I know the user closes tab or browser in html? 我如何知道用户或单个IP地址在我网站的页面上花了多长时间? - How do I know how long a user or a single IP address spent on a page of my site? 如何打开新的浏览器标签? - How do I open a new browser tab? 如何防止使用php或javascript在同一浏览器会话中打开另一个选项卡? - how to prevent opening another tab in same browser session with php or javascript? 在同一浏览器的另一个选项卡中打开了如何查找URL的区域 - how to find a URL is aready opened in another tab of same browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM