在政府医疗机构工作的乐趣之一是必须处理所有围绕PHI(受保护的健康信息)的偏执。不要误解我的意思,我支持尽一切可能保护人们的个人信息(健康状况、财务状况、上网习惯等),但有时人们会有点太神经质了。

举个例子:我们的一位州客户最近发现浏览器提供了保存密码的方便功能。我们都知道它已经存在了一段时间,完全是可选的,由最终用户决定是否使用它是一个明智的决定。然而,目前有一点骚动,我们被要求找到一种方法来禁用我们网站的功能。

问:网站有没有办法告诉浏览器不要提供记住密码的功能?我从事网络开发已经很长时间了,但我不知道我以前遇到过这种情况。

任何帮助都是感激的。


当前回答

Since most of the autocomplete suggestions, including the accepted answer, don't work in today's web browsers (i.e. web browser password managers ignore autocomplete), a more novel solution is to swap between password and text types and make the background color match the text color when the field is a plain text field, which continues to hide the password while being a real password field when the user (or a program like KeePass) is entering a password. Browsers don't ask to save passwords that are stored in plain text fields.

The advantage of this approach is that it allows for progressive enhancement and therefore doesn't require Javascript for a field to function as a normal password field (you could also start with a plain text field instead and apply the same approach but that's not really HIPAA PHI/PII-compliant). Nor does this approach depend on hidden forms/fields which might not necessarily be sent to the server (because they are hidden) and some of those tricks also don't work either in several modern browsers.

jQuery插件:

https://github.com/cubiclesoft/php-flexforms-modules/blob/master/password-manager/jquery.stoppasswordmanager.js

相关源代码来自上述链接:

(function($) {
$.fn.StopPasswordManager = function() {
    return this.each(function() {
        var $this = $(this);

        $this.addClass('no-print');
        $this.attr('data-background-color', $this.css('background-color'));
        $this.css('background-color', $this.css('color'));
        $this.attr('type', 'text');
        $this.attr('autocomplete', 'off');

        $this.focus(function() {
            $this.attr('type', 'password');
            $this.css('background-color', $this.attr('data-background-color'));
        });

        $this.blur(function() {
            $this.css('background-color', $this.css('color'));
            $this.attr('type', 'text');
            $this[0].selectionStart = $this[0].selectionEnd;
        });

        $this.on('keydown', function(e) {
            if (e.keyCode == 13)
            {
                $this.css('background-color', $this.css('color'));
                $this.attr('type', 'text');
                $this[0].selectionStart = $this[0].selectionEnd;
            }
        });
    });
}
}(jQuery));

演示:

https://barebonescms.com/demos/admin_pack/admin.php

点击菜单中的“添加条目”,然后滚动到页面底部的“模块:停止密码管理器”。

免责声明:虽然这种方法适用于视力正常的人,但屏幕阅读器软件可能存在问题。例如,屏幕阅读器可能会大声读出用户的密码,因为它看到的是纯文本字段。使用上述插件还可能产生其他不可预见的后果。改变内置的web浏览器功能应该通过测试各种各样的条件和边缘情况来进行。

其他回答

除了

autocomplete="off"

使用

readonly onfocus="this.removeAttribute('readonly');"

对于您不希望他们记住的输入表单数据(用户名,密码等),如下所示:

<input type="text" name="UserName" autocomplete="off" readonly 
    onfocus="this.removeAttribute('readonly');" >

<input type="password" name="Password" autocomplete="off" readonly 
    onfocus="this.removeAttribute('readonly');" >

在最新版本的主流浏览器(如谷歌Chrome, Mozilla Firefox, Microsoft Edge等)上进行了测试,效果非常好。

我测试了很多解决方案。动态密码字段名,多个密码字段(假密码不可见),更改输入类型从“text”到“password”,autocomplete=“off”,autocomplete=“new-password”,…但是最近的浏览器没有解决这个问题。

为了摆脱密码记忆,我最后把密码当作输入字段,并“模糊”输入的文本。

它不如本地密码字段“安全”,因为选择键入的文本会显示为明文,但密码不会被记住。它还依赖于激活Javascript。

你将不得不估计使用下面的建议和密码记住选项导航的风险。

虽然密码记忆可以由用户管理(每个站点取消),但它适用于个人计算机,不适用于“公共”或共享计算机。

我的案例是一个在共享计算机上运行的ERP,所以我将在下面尝试我的解决方案。

<input style="background-color: rgb(239, 179, 196); color: black; text-shadow: none;" name="password" size="10" maxlength="30" onfocus="this.value='';this.style.color='black'; this.style.textShadow='none';" onkeypress="this.style.color='transparent'; this.style.textShadow='1px 1px 6px green';" autocomplete="off" type="text">

网站有没有办法告诉浏览器不要提供记住密码的功能?

该网站通过使用<input type="password">告诉浏览器这是一个密码。所以如果你必须从网站的角度来做这件事,那么你就必须改变它。(显然我不建议这样做)。

最好的解决方案是让用户配置浏览器,这样它就不会记住密码。

autocomplete="off"不能在Firefox 31中禁用密码管理器,在一些早期版本中也很可能不能。

查看mozilla关于此问题的讨论: https://bugzilla.mozilla.org/show_bug.cgi?id=956906

我们希望使用第二个密码字段输入由令牌生成的一次性密码。现在我们使用文本输入而不是密码输入。:-(

由于Internet Explorer 11不再支持input type="password"字段的autocomplete="off"(希望其他浏览器不会效仿他们的做法),最简洁的方法(在撰写本文时)似乎是让用户在不同的页面提交他们的用户名和密码,即用户输入他们的用户名,提交,然后输入密码并提交。美国银行和汇丰银行的网站也在使用这种方法。

因为浏览器无法将密码与用户名关联起来,所以它不会提供存储密码的功能。这种方法适用于所有主流浏览器(在撰写本文时),无需使用Javascript也能正常运行。缺点是,它将更麻烦的用户,将采取2回传为一个登录操作,而不是一个,所以这真的取决于你的网站需要多安全。

更新:正如Gregory在这篇评论中提到的,Firefox将效仿IE11,忽略密码字段的autocomplete="off"。