我做了登录功能,所以当用户登录时,它将导航到其他页面,但问题是登录成功后,用户只需按物理后退按钮即可再次返回登录页面。现在我想要的是,在登录后,用户无法再次返回登录页面,因此当按下物理后退按钮时,它将关闭应用程序。这是我的onloginsucces方法
document.getElementById('auth').onclick = function () {
$fh.auth({
"policyId": "policyid",
"clientToken": "appid",
// Your App GUID
"endRedirectUrl": window.location.href,
"params": {
"userId": document.getElementById('username').value,
"password": document.getElementById('password').value
}
}, function(res) {
// Authentication successful - store sessionToken in variable
var sessionToken = res.sessionToken;
alert("Login Succes");
window.location = './menu.html';
}, function(msg, err) {
var errorMsg = err.message;
if (errorMsg === "user_purge_data" || errorMsg === "device_purge_data") {
// User or device has been black listed from administration console and all local data should be wiped
} else {
alert("Authentication failed - " + errorMsg);
}
})
};
除了使用窗口之外,还有其他方法吗。要导航的位置?就像窗户一样。也许可以替换,谢谢?
更新
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Hello World</title>
<link rel="stylesheet" href="css/app.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="cordova-2.7.0.js"></script>
<script type="text/javascript" src="js/jquery.min.1.9.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript">
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
//
function onBackKeyDown() {
e.preventDefault();
}
</script>
</head>