解决方案:某些网页Firefox不能记住密码

本文介绍了解决火狐浏览器在特定网站不保存密码的问题。通过修改配置文件nsLoginManager.js中的代码,使得浏览器忽略网页设置的autocomplete='off'属性,从而实现密码记忆功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script type="text/javascript"> document.body.oncopy = function() { if (window.clipboardData) { setTimeout(function() { var text = clipboardData.getData("text"); if (text && text.length>300) { text = text + "/r/n/n本文来自优快云博客,转载请标明出处:" + location.href; clipboardData.setData("text", text); } }, 100); } } </script> <script class="blogstory">function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>

Firefox 有个很方便的功能:记住密码。但是在某些网页上此功能却失效了,登陆时不提示保存密码,下次登录时又得重新输入,在登陆某些设置了较复杂密码的地方特别不方便。

为何会失效呢?其原因是网页作者在 input 中设置了 autocomplete 属性的值为 off

  1. < input   type = "text"   name = "pwd"   autocomplete = "off" >   
<input type="text" name="pwd" autocomplete="off">

当Firefox发现存在这个属性,就不会记住密码咯。

显然我们不可能通知网站作者去掉这个属性  :D   ,但并非没有办法解决。稍稍修改一下Firefox的配置文件即可搞定。

首先找到 nsLoginManager.js 文件。在Firefox安装目录下。例如:

C:/Program Files/Mozilla Firefox/components/nsLoginManager.js

搜索”_isAutoCompleteDisabled”,大约 719 行,可以看见如下片段

  1.      /*<br>  
  2.     * _isAutoCompleteDisabled<br>  
  3.     *<br>  
  4.     * Returns true if the page requests autocomplete be disabled for the<br>  
  5.     * specified form input.<br>  
  6.     */ <br>  
  7.    _isAutocompleteDisabled :  function  (element) {<br>  
  8.        if  (element && element.hasAttribute( "autocomplete" ) &&<br>  
  9.            element.getAttribute("autocomplete" ).toLowerCase() ==  "off" )<br>  
  10.            return   true ;<br>  
  11. <br>  
  12.        return   false ;<br>  
  13.    },  
     /*
* _isAutoCompleteDisabled
*
* Returns true if the page requests autocomplete be disabled for the
* specified form input.
*/
_isAutocompleteDisabled : function (element) {
if (element && element.hasAttribute("autocomplete") &&
element.getAttribute("autocomplete").toLowerCase() == "off")
return true;

return false;
},

将倒数第三行的 return true; 修改为 return false;
保存,重启Firefox即可生效。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值