我试图模拟使用英特尔XDK网页视图之前。在阅读Stack Overflow之前的一些文章之前,我读到了更好的归档方法是使用window.location = "url";
。它像一个魅力。
问题
现在我要绑定的硬件后退按钮,这样用户就可以确认是他想要或不关闭应用程序。问题是只有在window.location
不执行时才有效。
代码
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="cordova.js"></script>
<script>
window.location = "https://google.com";
var tried = false;
document.addEventListener("backbutton", backButton, false);
function backButton(){
if (tried){
navigator.app.exitApp();
}
else {
alert('TEST: Next time APP should close');
tried = !tried;
}
}
</script>
</head>
<body>
</body>
</html>
结果
评window.location
执行window.location
谢谢!