检测浏览器是否使用隐私浏览模式 [英] Detecting if a browser is using Private Browsing mode

查看:34
本文介绍了检测浏览器是否使用隐私浏览模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一家对安全有疑虑的公司构建一个外联网.他们希望确保(除其他外)他们的用户在浏览器的隐私浏览模式下浏览网站,这样就不会保留任何 cookie 或历史记录.

I'm building an extranet for a company paranoid about security. They want to make sure that (among other things) their users are browsing the site with the Private Browsing mode switched on in their web browser so that no cookies or history is kept.

我只找到了这个http://jeremiahgrossman.blogspot.com/2009/03/detecting-private-browsing-mode.htmlhttps://serverfault.com/questions/18966/force-safari-to-operate-in-private-mode-and-detect-that-state-from-a-webserver

理想的解决方案是不使用或最少使用 javascript.尝试为所有浏览器和平台设置唯一的 cookie 是否可行?以前有人这样做过吗?

The ideal solution would use no or minimal javascript. Would attempting to set a unique cookie work for all browsers and platforms? Anyone done this before?

谢谢!

更新

http://crypto.stanford.edu/~collinj/research/incognito/ 使用了其他发帖人提到的浏览器指纹识别器的 CSS 访问技术 - 感谢您的提示.

http://crypto.stanford.edu/~collinj/research/incognito/ uses the CSS visited technique of the browser fingerprinters mentioned by other posters- thanks for the hints.

我喜欢它,因为它小巧而优雅,但如果可能的话,仍然希望能够在没有 javascript 的情况下完成它.

I like it because it is small and elegant, but still want to be able to do it without javascript if possible.

推荐答案

2019 年 6 月更新

Google 正在移除在 Chrome 76 及更高版本中永久检测隐私浏览模式的功能.所以,如果你想检测隐私浏览,现在是不可能的(除非你找到了一种谷歌没有找到的方法).检测隐私浏览模式的能力已被确认为一个错误,并且从未打算这样做.

Google is removing the ability to detect Private Browsing Mode permanently in Chrome 76 onwards. So, if you're wanting to detect private browsing it's now impossible (unless you find a way to do it that Google hasn't found). The ability to detect private browsing mode has been acknowledged as a bug and was never intended.

对于遇到此问题的其他任何人,请注意,截至 2014 年,没有可靠或准确的方法来检测某人是否通过 Javascript 或 CSS 以隐身/隐私/安全浏览模式进行浏览.以前的解决方案曾经像 CSS 历史黑客一样有效,但后来被所有浏览器供应商渲染为无法使用.

永远不会出现需要在正常日常网站上检测隐私浏览模式的情况.人们出于自己的原因选择匿名浏览或不匿名浏览.

There should never be a situation where needing to detect private browsing mode on a normal day-to-day website is ever needed. People are choosing to browse anonymously and or not anonymously for their own reasons.

Chrome 和 Firefox 等浏览器不再禁用 localStorage 等功能.他们只是将它命名为一个临时位置,以防止使用它的网站出错.完成浏览后,命名空间将被删除,并且不会保存任何内容.如果您正在测试 localStorage 支持,而不管模式如何,对于支持它的浏览器,它将始终返回 true.

Browsers like Chrome and Firefox do not disable functionality like localStorage any more. They simply namespace it in a temporary location to prevent websites that use it from erroring out. Once you're finished browsing, the namespace is erased and nothing is saved. If you are testing for localStorage support regardless of mode, it will always return true for browsers that support it.

特别是在 Chrome 中检测隐私模式的其他方法已完全修补,将不再有效.

Other means of detecting private mode in Chrome specifically have been completely patched and will no longer work.

如果是公司内部需要,你应该开发一个浏览器插件.特别是 Chrome 和 Firefox,公开了内部 API,允许插件检查用户是否处于隐私浏览/隐身模式和相应的操作.它不能在插件之外完成.

If it is required internally by a company, you should develop a browser plugin. Chrome and Firefox, in particular, expose internal API's which allow plugins to check if the user is in private browsing/incognito mode and action accordingly. It cannot be done outside of a plugin.

这篇关于检测浏览器是否使用隐私浏览模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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