在政府医疗机构工作的乐趣之一是必须处理所有围绕PHI(受保护的健康信息)的偏执。不要误解我的意思,我支持尽一切可能保护人们的个人信息(健康状况、财务状况、上网习惯等),但有时人们会有点太神经质了。
举个例子:我们的一位州客户最近发现浏览器提供了保存密码的方便功能。我们都知道它已经存在了一段时间,完全是可选的,由最终用户决定是否使用它是一个明智的决定。然而,目前有一点骚动,我们被要求找到一种方法来禁用我们网站的功能。
问:网站有没有办法告诉浏览器不要提供记住密码的功能?我从事网络开发已经很长时间了,但我不知道我以前遇到过这种情况。
任何帮助都是感激的。
If you do not want to trust the autocomplete flag, you can make sure that the user types in the box using the onchange event. The code below is a simple HTML form. The hidden form element password_edited starts out set to 0. When the value of password is changed, the JavaScript at the top (pw_edited function) changes the value to 1. When the button is pressed, it checks the valueenter code here before submitting the form. That way, even if the browser ignores you and autocompletes the field, the user cannot pass the login page without typing in the password field. Also, make sure to blank the password field when focus is set. Otherwise, you can add a character at the end, then go back and remove it to trick the system. I recommend adding the autocomplete="off" to password in addition, but this example shows how the backup code works.
<html>
<head>
<script>
function pw_edited() {
document.this_form.password_edited.value = 1;
}
function pw_blank() {
document.this_form.password.value = "";
}
function submitf() {
if(document.this_form.password_edited.value < 1) {
alert("Please Enter Your Password!");
}
else {
document.this_form.submit();
}
}
</script>
</head>
<body>
<form name="this_form" method="post" action="../../cgi-bin/yourscript.cgi?login">
<div style="padding-left:25px;">
<p>
<label>User:</label>
<input name="user_name" type="text" class="input" value="" size="30" maxlength="60">
</p>
<p>
<label>Password:</label>
<input name="password" type="password" class="input" size="20" value="" maxlength="50" onfocus="pw_blank();" onchange="pw_edited();">
</p>
<p>
<span id="error_msg"></span>
</p>
<p>
<input type="hidden" name="password_edited" value="0">
<input name="submitform" type="button" class="button" value="Login" onclick="return submitf();">
</p>
</div>
</form>
</body>
</html>
面对同样的HIPAA问题,我找到了一个相对简单的解决方案,
创建一个隐藏密码字段,字段名为数组。
<input type="password" name="password[]" style="display:none" />
实际密码字段使用相同的数组。
/> . <input type="password" name="password[]
浏览器(Chrome)可能会提示你“保存密码”,但无论用户是否选择保存,下次登录时,密码将自动填充隐藏的密码字段,数组中的零槽,使第一个槽为空。
我尝试定义数组,例如“password[part2]”,但它仍然记得。我认为如果它是一个无索引数组,它就会丢弃它因为它别无选择,只能把它放在第一个位置。
然后使用你选择的编程语言访问数组,比如PHP,
echo $_POST['password'][1];
我在这个问题上苦苦挣扎了一段时间,并有了一个独特的解决方法。特权用户不能让保存的密码为他们工作,但普通用户需要它。这意味着特权用户必须登录两次,第二次强制不保存密码。
有了这个要求,标准的autocomplete="off"方法并不适用于所有浏览器,因为密码可能是从第一次登录时保存的。一位同事找到了一种解决方案,在关注新密码字段时替换密码字段,然后关注新密码字段(然后连接相同的事件处理程序)。这是有效的(除了它在IE6中造成了一个无限循环)。也许有办法,但这让我头疼。
最后,我尝试将用户名和密码放在表单之外。令我惊讶的是,这竟然起作用了!它可以在IE6上运行,也可以在Linux上运行当前版本的Firefox和Chrome。我还没有进一步测试它,但我怀疑它在大多数(如果不是所有)浏览器中都能运行(但如果有一种浏览器不关心是否没有表单,我也不会感到惊讶)。
下面是一些示例代码,以及一些jQuery来让它工作:
<input type="text" id="username" name="username"/>
<input type="password" id="password" name="password"/>
<form id="theForm" action="/your/login" method="post">
<input type="hidden" id="hiddenUsername" name="username"/>
<input type="hidden" id="hiddenPassword" name="password"/>
<input type="submit" value="Login"/>
</form>
<script type="text/javascript" language="JavaScript">
$("#theForm").submit(function() {
$("#hiddenUsername").val($("#username").val());
$("#hiddenPassword").val($("#password").val());
});
$("#username,#password").keypress(function(e) {
if (e.which == 13) {
$("#theForm").submit();
}
});
</script>
我周围有个工作,可能会有帮助。
你可以自定义字体。所以,做一个自定义字体,所有的字符为点/圆/星号为例。使用它作为你网站的自定义字体。检查如何做到这一点在inkscape:如何使自己的字体
然后在你的登录表单上使用:
<form autocomplete='off' ...>
<input type="text" name="email" ...>
<input type="text" name="password" class="password" autocomplete='off' ...>
<input type=submit>
</form>
然后添加css:
@font-face {
font-family: 'myCustomfont';
src: url('myCustomfont.eot');
src: url('myCustomfont?#iefix') format('embedded-opentype'),
url('myCustomfont.woff') format('woff'),
url('myCustomfont.ttf') format('truetype'),
url('myCustomfont.svg#myCustomfont') format('svg');
font-weight: normal;
font-style: normal;
}
.password {
font-family:'myCustomfont';
}
很好的跨浏览器兼容性。我尝试过IE6+、FF、Safari和Chrome浏览器。只要确保你转换的oet字体不会被损坏。希望有帮助?