autocomplete方法

https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion#The_autocomplete_attribute_and_login_fields

对于普通的表单区域 此属性设置为 off,具有阻止浏览器记忆的功能

Setting autocomplete="off" here has two effects:

  • it stops the browser saving field data for later autocompletion on similar forms though heuristics that vary by browser.
  • it stops the browser caching form data in session history. When form data is cached in session history, the information the user has filled in will be visible after the user has submitted the form and clicked on the Back button to go back to the original form page.

但是对于登录页面,不行。

The autocomplete attribute and login fieldsEdit

Modern browsers implement integrated password management: when the user enters a username and password for a site, the browser offers to remember it for the user. When the user visits the site again, the browser autofills those login fields with the stored values.

Additionally, the browser enables the user to choose a master password that the browser will use to encrypt stored logins.

Even without a master password, in-browser password management is generally seen as a net gain for security. Since users don't have to remember passwords that the browser stores for them, they are able to choose stronger passwords than they would otherwise.

For this reason, many modern browsers do not support autocomplete="off" for login fields.

  • if a site sets autocomplete="off" for a form, and the form includes username and password input fields, then the browser will still offer to remember this login, and if the user agrees, the browser will autofill those fields the next time the user visits this page.
  • if a site sets autocomplete="off" for username and password input fields, then the browser will still offer to remember this login, and if the user agrees, the browser will autofill those fields the next time the user visits this page.

This is the behavior in Firefox (since version 38), Google Chrome (since 34), and Internet Explorer (since version 11).

登录页面规避记忆方法

http://www.cnblogs.com/happyfreelife/p/4240100.html

此博文推荐在 密码框前 添加一个隐藏的 密码框:

<input type="password" style="display: none;">

和ajax提交。

http://blog.csdn.net/nms312/article/details/39050419

此博文推荐在聚焦的时候 才改变输入框类型为password

<input type="text" name="password" onfocus="this.type='password'" autocomplete="off"/>

http://blog.csdn.net/ldevs/article/details/39671813

此博文推荐在提交前将密码框清空, 实际提交的密码使用隐藏的 hidden控件。

此法逻辑上更加自然, 引入一个提交用的隐藏控件, 清空可见控件,并改变可见控制内容为空。 推荐!!

很多浏览器都会记住用户密码,如果偶尔在一台机器上登录系统密码容易被记住,别人能轻松登录,通过以下方法可以轻松防止密码被浏览器记住,被他人非法使用

1、使用随机数生成方式生成一个随机数加上前缀生成一个密码输入框的id

id 如 PWD_12332

<input type="password" id="PWD_12332" />

每次都是不同的id做密码框的id

2、实际密码提交的文本框隐藏

<span style="font-size:18px;"><input id="password" name="password" type="hidden" /></span>

3、表单提交前将 密码输入框的内容 搬到隐藏的文本框中

4、清空密码输入框,清空密码框后浏览器应该没东西记了。

下一次登录时密码框的id会改变,谁也不知道是什么,浏览器能知道吗,大家可以试试!!!

验证代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>

</head>
<body>
  <form action="index.php">
    <input type="text" > user
    <input type="password"> password
    <button type="submit">submit</button>
  </form>
  <script>
    $("[type='submit']").click(function  () {
     
      alert($("[type='password']").val())

$("[type='password']").val("") //将密码赋值为 空,则不会触发chrome记忆

alert($("[type='password']").val())

//return false
    })
  </script>
</body>
</html>

不是每次都生效。

验证代码-修改type,完美解决方案

http://stackoverflow.com/questions/32775342/how-to-disable-chromes-saved-password-prompt-setting-through-javascript?answertab=oldest#tab-top

https://github.com/cloudfour/hideShowPassword/issues/1

https://www.bing.com/search?q=type+property+can%27t+be+changed&pc=MOZI&form=MOZSBR

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/try...catch

/*

动态检测浏览器能力,是否支持 input type类型(text和password)互相转换。

*/

function CanTextAndPasswordSwitch_InputType()

{

var pass = document.createElement('input');

pass.type = 'text';

pass.style.display = "none";

document.body.appendChild(pass);

var retVal = true;

try

{

/* IE7 IE8此语句会报js错误,走catch分支 */

pass.type = 'password';

if ( "password" == pass.type )

{

/* console.log(" input type text to password allow! "); */

/* password转换为text类型测试 */

pass.type = 'text';

/* text 和 password 类型可以互转 */

if ( "text" == pass.type )

{

retVal = true;

}

else

{

retVal = false;

}

}

else

{

/* console.log(" input type text to password not allow! "); */

retVal = false;

}

}

catch(e)

{

/* console.log(" input type text to password not allow! exception"); */

retVal = false;

}

document.body.removeChild(pass);

return retVal;

}

<input type="password" name="Frm_Password" id="Frm_Password" autocomplete="off" class="w180"/>

方案:绕开chrome的记忆密码规则,在页面初始化过程中,设置密码框为 text,

当光标落入密码框,再将类型修改为 password。

参考:http://blog.csdn.net/nms312/article/details/39050419 */

if ( CanTextAndPasswordSwitch_InputType() ) {

var passwordObj = document.getElementById("Frm_Password");

passwordObj.type = "text";

passwordObj.onfocus = function () {

this.type = "password";

}

}

chrome浏览器不允许记忆登录账户的方法的更多相关文章

  1. 在CMD下启动vmware、Xshell连接虚拟机以及控制Chrome浏览器自动执行js登录校园网

    标题有点长,主要是写个bat出来玩玩, (1)不用每次都手动关闭mysql服务(我不想把它设为手动启动,有强迫症) (2)然后希望每次vmware能自动连上虚拟机 (3)以及每次Xshell都能自动启 ...

  2. 解决win8下chrome浏览器打开提示没有注册类的方法

    今天又把win8装回来了,继续装了个chrome浏览器,但是发现只能从安装的文件打开,从快捷方式或者快速启动栏都会提示没有注册类.找到一种解决的办法是删除注册表中的相关键值,具体如下: 1.打开注册表 ...

  3. Chrome浏览器清除页面js文件缓存的方法

    Chrome浏览器清除页面js文件缓存 Chrome浏览器清除js缓存方法虽然简单,但有些人还是不太会,有些人会去设置里面清除有时候没有用,这里写一下简单步骤,使用一次以后就会了,而且速度更快 1.打 ...

  4. Python selenium执行多个测试脚本时,浏览器多次打开登录账户

    当类里面定义了 setUp() 方法的时候,测试程序会在执行每条测试项前先调用此方法:同样地,在全部测试项执行完毕后,tearDown() 方法也会被调用. 所以当在setUp()中执行打开浏览器后, ...

  5. chrome浏览器默认启动时打开2345导航的解决方法

    2345并没有改动chrome内部设置.它仅仅是把全部的快捷方式改动了.包含開始菜单旁边的快捷启动图标. 仅仅须要右键chrome快捷方式.在目标一栏中,把"----chrome.exe&q ...

  6. chrome浏览器设置自动切换代理上网的方法

    利用shadowsocks代理软件实现FQ时,如果都走代理模式,流量肯定不够.可以利用chrome的SwitchyOmega插件实现自动根据URL来决定是否使用代理.设置如下: 1.安装Switchy ...

  7. Appium(Python)驱动手机Chrome浏览器

    手机Chrome浏览器访问淘宝H5与在电脑上访问淘宝H5是一摸一样的: 第一种方法: 直接在电脑Chrome浏览器上打开F12: 第二种方法: 手机连接电脑后, 在手机Chrome浏览器上打开淘宝H5 ...

  8. Chrome浏览器插件开发-淘宝自动登录

    浏览器插件的介绍 Chrome浏览器插件开发的准备工作 manifest.json配置介绍 页面如何注入scripts文件 一. 浏览器插件的介绍 浏览器插件是一种遵循一定规范的应用程序接口编写出来的 ...

  9. Postman+Postman interceptor的安装和使用-解决把chrome浏览器登录状态同步到postman进行有依赖的接口测试 Postman 使用方法详解

    Postman+Postman interceptor的安装和使用-解决把chrome浏览器登录状态同步到postman进行有依赖的接口测试   问题引入:做接口测试时,有依赖关系的接口往往不好测试( ...

随机推荐

  1. ACM 阶乘之和

    阶乘之和 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 给你一个非负数整数n,判断n是不是一些数(这些数不允许重复使用,且为正数)的阶乘之和,如9=1!+2!+3! ...

  2. 3分钟wamp安装redis扩展超级简单

    windows10(win8.1等系统应该是一样的) wampserver2.5 -Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b 很简单只需要3步,主要是安装redi ...

  3. 好的 iOS 代码习惯

    一,使用别人的框架时,尽量在退出时移除框架创建的对象 if (_giftToastView) { [_giftToastView removeFromSuperview]; _giftToastVie ...

  4. Poj 3250 单调栈

    1.Poj 3250  Bad Hair Day 2.链接:http://poj.org/problem?id=3250 3.总结:单调栈 题意:n头牛,当i>j,j在i的右边并且i与j之间的所 ...

  5. Invalid escape sequence(valid ones are \b \t \n \f \r \" \' \\)

    Invalid escape sequence(valid ones are \b \t \n \f \r \" \' \\) 在运行eclipse的相关程序代码时遇到了报错信息,查看控制台 ...

  6. linux下搭建svn代码库

    1.安装svn客户端 2.创建svn代码库 1.安装svn客户端 1.1.使用命令安装 1)CentOS $ yum install subversion 2)ubuntu sudo apt-get ...

  7. mongodb数据导入导出以及备份恢复

    昨日在公司收到游戏方发来一个1G多的数据文件,要求导入联运账号中.细细一看,纳尼!文件竟然是BSON格式. 哇塞,这不是去年给大家分享的NoSql中的MongoDB的备份文件吗? 于是搭好环境 1.启 ...

  8. 李洪强iOS经典面试题128

    1.写一个NSString类的实现 + (id)initWithCString:(c*****t char *)nullTerminatedCString encoding:(NSStringEnco ...

  9. 实现AJAX的基本步骤 。。转

    要完整实现一个AJAX异步调用和局部刷新,通常需要以下几个步骤: (1)创建XMLHttpRequest对象,也就是创建一个异步调用对象. (2)创建一个新的HTTP请求,并指定该HTTP请求的方法. ...

  10. hadoop Error: JAVA_HOME is not set and could not be found.

    Hadoop安装完后,启动时报Error: JAVA_HOME is not set and could not be found.解决办法:        修改/etc/hadoop/hadoop- ...