ChildBrowser on PhoneGap Build with Cordova

by Steven6. September 2012 08:46

It's taken quite a bit of effort to get this working with all the things that have been happening around PhoneGap and Cordova recently, but as of today, this works.

You can find the code on my github account.

Here is the config.xml

<?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns = "http://www.w3.org/ns/widgets"
        xmlns:gap = "http://phonegap.com/ns/1.0"
        id        = "com.phonegap.example"
        versionCode="10" 
        version   = "1.0.0">
 
    <name>Cordova Browser Example</name>
 
    <description>
        An example for Cordova browsing.
    </description>
 
    <preference name="phonegap-version" value="1.9.0" />
    <gap:plugin name="ChildBrowser" version="3.0.4" /> 
 
</widget>

Here is the index.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name = "format-detection" content = "telephone=no"/>
        <meta name="viewport" content="user-scalable=no, initial-scale=1, 
maximum-scale=1, minimum-scale=1, width=device-width;" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello Cordova Browser</title>
    </head>
    <body>
        Launching ...
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="childbrowser.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>
    </body>
</html>
 

Here is the JavaScript:

var app = {
    initialize: function() {
        this.bind();
    },
    bind: function() {
        document.addEventListener('deviceready', this.deviceready, false);
    },
    deviceready: function() {
setTimeout(function() {
console.log('launching ...');
window.plugins.childBrowser.showWebPage('http://www.google.com', 
{ showLocationBar: false });
console.log('launched ...');
}, 5000);
    }
};
 

Enjoy!

Tags: ,

Tech

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

 
Steven Livingstone-Perez is VP Engineering at KILTR, creator of Valebrity and other things. He is married & has two children.
 
He mains the VentureIQ blog focusing on tools for startups.

Books I've Written

What I Do

undefined

Founder

 

undefined

VP Engineering