Your code worked perfectly on iPhone using Intel XDK App Preview, have you added <script src="cordova.js"></script>
to the index.html
.
However in the XDK emulator it does not work, localStorage.setItem() does not seem run in simulated inappbrowser.
But the same code on iPhone works, here is the code:
<!DOCTYPE html>
<html>
<head>
<title>App</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="cordova.js"></script>
<script>
function showGamesPage() {
var win = window.open("https://c9.io/.../test.html", "_blank", "EnableViewPortScale=yes");
win.addEventListener("loadstop", function() {
win.executeScript({ code: "localStorage.setItem('name', '' );" });
var loop = setInterval(function() {
win.executeScript({ code: "localStorage.getItem( 'name' );"},
function(values) {
var name = values[0];
if (name) {
clearInterval(loop);
alert("Caught!");
win.close();
}
}
);
});
});
}
</script>
<style>
body{background-color: white}
</style>
</head>
<body>
<h1 onclick="showGamesPage()">Open</h1>
</body>
</html>