这可能是How can I get browser to prompt to save password?
的副本我已经考虑了发布到上述查询的所有要点。
“保存密码”提示在chrome和Firefox中工作正常。 但是我无法在IE和Safari浏览器中看到保存密码提示。
这是多页注册表格。成功注册后,将调用保存密码提示。验证电子邮件后,URL会更改,并且对于设置密码和注册成功页面而言,URL保持不变。成功设置密码后,必须出现“保存密码”提示。
html:
<form method="post" autocomplete="on">
<input type="text" name="username" id="username" autocomplete="on" style="display:none">
<input type="password" name="password" id="password" autocomplete="on">
<input type="button" name="loginButton" id="loginButton" onclick="loginAction()">
<input type="submit" name="loginSubmit" id="loginSubmit" onsubmit="loginSubmit()" style="display:none">
</form>
脚本:
function loginAction () {
//form validation
//ajax call
//on success of ajax call
//before changing the html content
//submitting form
var submitButton = document.getElementById("loginSubmit");
submitButton.click();
//changing the html content in the same state.
}
function loginSubmit () {
//doing nothing simple check for form validation, already validated in loginAction
history.pushState({}, "", window.location.href); //emulating navigation
}