停止浏览器存储访问历史记录
我目前正在开发一个妇女庇护所网站。由于这对于使用该网站的人来说是非常敏感的信息,因此我想阻止浏览器存储他们的访问历史记录。使用 HTML5 History API 之类的东西可以实现这一点吗?理想情况下,它也适用于 IE6+,因为有很多人使用旧版本的 IE。
我知道浏览器有隐私浏览模式,但大多数人不知道它们,所以一些自动方式是最好的。
一种潜在的(尽管不太受欢迎)的解决方案是提示人们使用隐私浏览模式(如果他们目前没有这样做)。是否可以通过 JavaScript 检测到这一点?
编辑:我接受了 Virgil 的回答,因为教育是最好的选择,因为他们可能也需要将学到的知识应用到其他网站。我还在“隐藏我的访问”按钮上使用了 Joseph 的 location.replace
,这样它就禁用了后退按钮。
值得注意的一件有趣的事情是,我尝试在网站上的所有链接上使用 history.replace
,认为这会替换所有浏览器历史记录,意味着只记住最后查看的页面。然而,在 Firefox 中打开历史记录面板(未在其他浏览器中进行测试)仍然显示所查看的每个页面的日志,只是无法通过后退按钮访问它们。
因此,对于任何有类似疑问的人,我想重申,教育用户是保护他们的第一步。谢谢大家的建议。
问候
里克
I am currently developing a website for a women's refuge. As this is very sensitive information for those using the site I'd like to stop the browser from storing any history of their visit. Is this possible using something like the HTML5 History API? Ideally it would work in IE6+ too as there are a lot of people using old versions of IE.
I know browsers have Private Browsing modes, but most people don't know about them, so some automatic way would be best.
One potential (although less preferred) solution would be to prompt people to use Private Browsing mode if they aren't currently do so. Is it possible to detect this via JavaScript?
EDIT: I've accepted Virgil's answer as eduction is the best option as they may need to apply what they learnt to other sites too. I've also used Joseph's location.replace
on the hide my visit button so it disables the back button.
One interesting thing to note is I tried using history.replace
on all links on the site thinking this would replace all browser history meaning only the last page viewed was remembered. However opening the history panel in Firefox - not tested in other browsers - still showed a log of every page viewed, they were just inaccessible via the back button.
So, for anyone with a similar query, I'd like to reiterate that educating the user is the first step in protecting them. Thanks everyone for you advice.
Regards
Ric
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不幸的是这是不可能的。用户必须采取行动才能删除其历史记录。我建议您发出警告,以便女性可以删除她们的历史记录,并且您可以包含针对每个主要浏览器的说明。对于 HTML5 和 JavaScript,这在 IE6 中是不可能的,因为它不支持 HTML5。
Unfortunately this is not possible. User action would have to be taken to delete their history. I suggest you put up a warning so women can delete their history and you can include instructions for every major browser. In regards to HTML5 and JavaScript this would not be possible in IE6 as it doesn't support HTML5.
一种方法是使用 locarion.replace(url) 使所有导航完全通过 javascript 进行。这不会保存历史状态,但也意味着用户也无法真正使用书签。对于链接,它将类似于此
Or
或类似的。
One way to do it is to make all navigation go exclusively through javascript using locarion.replace(url). This does not save a history state but also means the user could not really use bookmarks either. For a link, it would be similar to this
Or
or similar.
好吧,虽然我不认为你可以“强迫”用户使用隐私浏览,但你可以给他们一切机会来避免历史记录。
例如,让站点尝试存储 cookie(来自服务器并使用 JavaScript 等语言)。如果服务器可以在下次访问时重新检测到 cookie,请将其重定向到“使用隐私浏览[方法如下]或自行承担风险”类型的登陆页面。
这大约是唯一的解决办法。
当然,我也会实现 SSL,但我认为这更为隐含。
Well, though I don't think you can "force" users to use private browsing, you can give them every opportunity to avoid the history.
For example, have the site attempt to store a cookie (both from the server and using a language like javascript). If the server can then re-detect the cookie on the next visit, redirect them to a "Use private browsing [and here's how] or proceed at your own risk" kind of landing page.
That about the only way around it.
I, of course, would also implement SSL, but I think this is more implied.
解决方案不是使用 HTTPS 吗?我很确定浏览器不会存储这些网站的历史记录。
Wouldn't the solution be to use HTTPS? I am pretty sure browsers don't store the history for those sites.