如何禁用浏览器默认密码弹出窗口?

sim*_*ple 5 html javascript google-chrome

  1. 我正在开发一个Google Chrome插件.
  2. 在选项页面下,我正在向需要PASSWORD的服务器运行AJAX请求
  3. 如果密码不正确,我只想抓住错误,但浏览器会给出一个弹出窗口.

替代文字http://img834.imageshack.us/img834/2905/browserproblem.png

我可以禁用它以及如何禁用它?

old*_*boy 4

问题是您\xe2\x80\x99 没有对您\xe2\x80\x99 发送的用户名(即身份验证令牌)和(虚拟)密码进行Base64 编码(这是HTTP 基本身份验证方案的要求)。Here\xe2\x80\x99s 您的代码大致应如下所示:

\n\n
var xhr = new XMLHttpRequest();\nxhr.open('GET', 'http://onsip.highrisehq.com/account.xml');\nxhr.setRequestHeader('Authorization', 'Basic ' + btoa(token + ':'));\nxhr.onreadystatechange = function() { console.log(xhr.responseText); };\nxhr.send();\n
Run Code Online (Sandbox Code Playgroud)\n\n

(我为你交换了'onsip'子域名,但你仍然需要替换token子域,但您仍然需要替换为您的身份验证令牌。)

\n