This question was raised several times already. But I am still struggling with the issue with no idea how to solve it.
My very primitive app code:
<!DOCTYPE html>
<html>
<head>
<title>Standalone Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
var iabRef = null;
function onDeviceReady() {
iabRef = window.open('http://example.com', '_blank', 'location=no', 'zoom=no', 'hardwareback=yes');
iabRef.addEventListener('exit', iabClose);
}
function iabClose(event) {
iabRef.removeEventListener('exit', iabClose);
}
</script>
</head>
<body>
</body>
</html>
On phonegap forum I read that Android hardware back button functionality was added by default. But it doesn't work for me, still.
desired behaviour: navigate through several links on a page, tap back and see previous pages, according to history.
actual behaviour: after navigating through several links and tapping back inAppBrowser is closed, I see white screen instead of a previous page.
As you can see I added hardwareback property also, but with no luck. Also I tried ti hijack back button behaviour with putting this code inside onDeviceReady function:
document.addEventListener("backbutton", function(e){
e.preventDefault();
navigator.app.backHistory()
}, false);
And again no luck. Tried on several different devices, all the same. I guess there is a very simple thing I am missing. Any ideas?
If it matters, I build the app on build.phonegap.com.
window.history.back()usinginAppBrowserRef.executeScript({ code: scriptErrorMesssage })? - daserge