Context
I am trying to simulate a WebView using the Intel XDK. Before reading the stack overflow message, I read that the best way to archive is to use window.location = "url";. It worked like a charm.
Problem
Now I want to bind the hardware stand so that the user can confirm whether he wants or does not close the application. The problem is that it only works if window.locationit is not executed.
the code
<!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>
results
Commenting window.location

Performance window.location

Thank!
source
share