Skip to content

Instantly share code, notes, and snippets.

@macdonst
Created September 9, 2011 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macdonst/1206564 to your computer and use it in GitHub Desktop.
Save macdonst/1206564 to your computer and use it in GitHub Desktop.
ChildBrowser Example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Child Browser Example</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="childbrowser.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
function init(){
document.addEventListener("deviceready", onDeviceReady, false);
}
// PhoneGap is ready
//
function onDeviceReady() {
console.log("PhoneGap is ready");
}
function locationChanged(newurl) {
console.log("The JS got this url = " + newurl);
}
function closed() {
console.log("The JS got a close event");
}
function showPage(locbar) {
window.plugins.childBrowser.onLocationChange = locationChanged;
window.plugins.childBrowser.onClose = closed;
window.plugins.childBrowser.showWebPage("http://www.phonegap.com", {
showLocationBar: locbar
});
}
function openExternal() {
window.plugins.childBrowser.openExternal("http://www.phonegap.com");
}
</script>
</head>
<body onload="init()" id="stage" class="theme">
<a href="#" class="btn large" onclick="showPage(true); return false;">Show Page</a></p>
<a href="#" class="btn large" onclick="showPage(false); return false;">Show Page No Toolbar</a></p>
<a href="#" class="btn large" onclick="openExternal(); return false;">Old ChildBrowser</a></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment