如何检测IE中的另一个窗口中已经打开了同一页面 [英] How to detect that the same page is already opened in another window in IE

查看:151
本文介绍了如何检测IE中的另一个窗口中已经打开了同一页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法检查我的页面是否未在IE中的另一个标签页或窗口中打开?假设我有Page1,用户点击新窗口,这将打开一个打开同一页面的新窗口。所以现在页面有两个实例。我想限制浏览器在任何给定时间只打开一个页面实例。

Is there any way to check that my page is not opened in another tab or window in IE? Say I have Page1 and user hits "new window", which will open a new window with the same page opened. So now there are two instances of the page. I want to restrict the browser to only have one instance of the page opened at any given time.

其中一个要求是用户必须能够刷新页面和应用程序内部仍处于相同状态。因此,一次性令牌不合适。

One of the requirements is that users must be able to refresh the page and still be in the same state inside the application. So one-time tokens are not suitable.

不确定是否有任何方法可以区分页面刷新和打开的新窗口,这就是我要问的原因。

Not sure that there is any way to distinguish between a page refresh and a new window opened, that's why I'm asking.

PS这不是一个普通的网站,我明白这样做通常会是侵入性和邪恶的。这里有一个很好的例子,因为它是一个庞大的Web应用程序。

P.S. This is not for a normal website, and I understand that doing this usually would be intrusive and evil. There is a strong case to do this here, as it is a massive web application.

推荐答案

实现这个的最好方法是通过拥有服务器端令牌(许多银行这样做),在每次请求时重新生成,并且必须传回以使页面正常运行。

The best way to implement this is by having a server side token (many banks do this) that is regenerated at each request and must be passed back for the pages to function.

所以基本上:


  1. 您将生成的令牌附加到每个
    链接(作为查询字符串的一部分)

  2. 您收到的任何不包含令牌的请求都可视为无效。

  3. 在每次请求时生成一个新令牌,以便任何时候只有1个令牌有效

这篇关于如何检测IE中的另一个窗口中已经打开了同一页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆