如何避免开两个浏览器窗口? [英] How to avoid opening two browser windows?

查看:138
本文介绍了如何避免开两个浏览器窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想避免打开两个应用程序窗口(或标签)的可能性。这是,如果安装上的 http://www.domain.com 的我的应用程序(LAMP + JavaScript)的和用户正在浏览的网页的 http://www.domain.com/用户/ 的他/她不能像打开的 http://www.domain.com/system/ 的另一扇窗。如果他/她会打开另一个窗口,应用程序应该显示错误信息。

I'd like to avoid the possibility to open two application windows (or tabs). It is, if my app (LAMP+Javascript) is installed on http://www.domain.com and the user is browsing the page http://www.domain.com/user/ he/she cannot open another window like http://www.domain.com/system/. If he/she opens another window, the application should show an error message.

这可能吗?

对于好奇的人:我需要这样的行为,因为我的应用程序使用一些会话数据来识别的动作序列。如果用户打开在同一个浏览器的新窗口,通常一切是正确的,但如果他/她开始一个新的序列中,previous之一(另一个窗口)都将丢失。

For curious people: I need this behaviour because my app uses some session data to identify sequences of actions. If the user opens a new window on the same browser, normally everything is right, but if he/she starts a new sequence, the previous one (in the other window) will be lost.

推荐答案

虽然这是正确的什么都别人在这里说,你不能打开你的网站两次prevent人,有可能是你的解决方法。请注意,这不是一个100%的解决方案,将要求开发在此基础上进一步code。

While it is correct what all others said here that you cannot prevent someone from opening your website twice, there might be a workaround for you. Note that this is not a 100% solution and will require you to develop further code based on this.

据我了解,你有以下的问题:

As far as I understand you have the following problems:


  1. 如何确定用户是否有你的页面与共享会话数据(在Chrome即两个选项卡,2 Chrome窗口等)的窗口/标签打开 - 这是最简单的一部分,虽然

  2. 如何确定用户是否有你的网页在不同浏览器中打开(即在开放FF&放大器;镀铬一次) - 这是棘手的

不过 - 你可以使用 LSO - 本地共享对象来做到这一点。这些是存储在客户端Flash基于Cookie类似的数据块。他们是跨浏览器和放大器;跨域兼容。你可以找到一个名为EVERCOOKIE一个很好的库使用它们这里

However - you could use LSO - Local Shared Objects to accomplish this. These are Flash based cookie similar data pieces stored at the client's side. AND THEY ARE CROSS-BROWSER & CROSS-DOMAIN COMPATIBLE. You can find a nice library called EVERCOOKIE for using them here.

通过设置这样一个cookie,你将能够跟踪用户即使他打开了一个新窗口或即使他打开你的网页在不同的浏览器,就浏览器共享相同的Flash安装等。

By setting such a cookie you will be able to trace the user even if he opens a new window or even if he opens your page in a different browser, as far as the browsers share the same Flash installation etc.

请注意,这不会prevent有人直接开两个窗口,但它让你送他到相同的序列状态,因为他是在例如另一个窗口。

Note that this will not prevent someone in opening two windows directly, but it enables you to send him to the same sequence state as he is in the other window for example.

您也应该知道,这不是一个100%的解决方案。总会有一些技巧来解决这个问题,但我认为普通用户将无法得到它...

You should also be aware that this is not a 100% solution. There will always be some trick to get around this, although I think normal users would not be able to get it...

这篇关于如何避免开两个浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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