iT邦幫忙

0

如何在JS中寫判定轉業面

(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();
    }
}

})();

dragonH iT邦超人 5 級 ‧ 2019-05-06 20:50:30 檢舉
這個不是純js吧 是不是有用什麼 PhoneGap 的框架
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
舜~
iT邦高手 1 級 ‧ 2019-05-17 08:59:36

你可以用個全域變數來存頁面堆疊,想知道上一頁就查堆疊就可以了

這個堆疊可以放在cookie/session/...等全域中即可

我要發表回答

立即登入回答