我已经使用 Phonegap Build 构建了一个本机应用程序。有没有办法在外部网站的 webview 中自动登录(嵌入 inappbrowser)。
应用程序启动,然后用户将重定向到网站进行登录。但用户必须一次又一次地输入用户名和密码。是否可以自动登录?我读过有关本地存储的内容。这可以通过外部网站上的 inappbrowser 实现吗(无法访问我知道的phonegap 插件)。
是的,这应该是可能的。您只需要将正确的处理程序连接到loadstop事件,然后在提交后使用本地存储来存储用户名和密码,如果已经存在,则自动填充它们。
function loadStopped() {
// Here use JavaScript to manipulate the actual page on hand.
// Can't really give better description about what to do, but something like this:
var username = "";
if (localStorage.getItem("username") !== null) {
username = localStorage.getItem("username");
}
var password = "";
if (localStorage.getItem("password") !== null) {
password = localStorage.getItem("password");
}
document.getElementById("username_field").value = username;
document.getElementById("password_field").value = password;
// document.getElementById("the_form").submit();
document.getElementById("the_form").addEventListener("submit", function() {
localStorage.setItem("username", document.getElementById("username_field").value);
localStorage.setItem("password", document.getElementById("password_field").value);
});
}
ref = window.open('http://google.com', '_self', 'location=yes');
ref.addEventListener('loadstop', loadStopped);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)