(function () {
"use strict";
document.addEventListener('deviceready', onDeviceReady.bind(this), false);
function onDeviceReady() {
$("#login").on("click", login);
};
function login() {
var id = document.getElementById("id").value;
var password = document.getElementById("password").value;
if (id != "" && password != "") {
if (id.toLowerCase() == "123" && password == "456") {
navigator.notification.alert(
"恭喜,登入成功!",
alertDismissed,
"登入",
"確定"
);
} else if (id.toLowerCase() == "123") {
navigator.notification.prompt(
"密碼不正確,請輸入密碼",
onPrompt,
"登入",
["確定", "取消"],
""
);
} else {
navigator.notification.confirm(
"帳號錯誤!",
onConfirm,
"登入",
["重新輸入", "結束程式"]
);
}
} else {
alert("登入帳號及密碼都必須輸入!");
}
}
function alertDismissed() { }
function onPrompt(results) {
if (results.buttonIndex == 1) {
if (results.input1 == "456") {
alert("恭喜,登入成功!");
password.value = results.input1;
} else {
alert("密碼不正確!")
}
}
}
function onConfirm(buttonIndex) {
if (buttonIndex == 1) {
id.value = "";
password.value = "";
} else {
navigator.app.exitApp();
}
}
})();
你可以用個全域變數來存頁面堆疊,想知道上一頁就查堆疊就可以了
這個堆疊可以放在cookie/session/...等全域中即可