Created
January 14, 2014 15:19
-
-
Save jerkovicl/8419951 to your computer and use it in GitHub Desktop.
Retrieve data from InAppBrowser (Icenium) http://www.icenium.com/blog/icenium-team-blog/2013/12/31/phonegap-apache-cordova-lifecycle-events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>InAppBrowser Tester</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link href="kendo/styles/kendo.mobile.all.min.css" rel="stylesheet"> | |
<link href="styles/main.css" rel="stylesheet"> | |
<script src="cordova.js"></script> | |
<script src="kendo/js/jquery.min.js"></script> | |
<script src="kendo/js/kendo.mobile.min.js"></script> | |
</head> | |
<body> | |
<div data-role="view"> | |
<div> | |
<h1>Welcome!</h1> | |
<button data-role="button" data-click="app.setName">Set Name</button> | |
</div> | |
</div> | |
<script> | |
window.app = { | |
load: function() { | |
navigator.splashscreen.hide(); | |
new kendo.mobile.Application( document.body ); | |
}, | |
setName: function() { | |
var win = window.open( "http://jsfiddle.net/tj_vantoll/K2yqc/show", "_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 ); | |
win.close(); | |
$( "h1" ).html( "Welcome " + name + "!" ); | |
} | |
} | |
); | |
}); | |
}); | |
} | |
}; | |
document.addEventListener( "deviceready", app.load ); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment