...

View Full Version : ChildBrowser + Cordova 1.7 errors please help - not an object



jarv
05-30-2012, 11:35 PM
Hi, I am trying to follow this tutorial:
PhoneGap Tutorial Series #4 Third-Party Plugins (ChildBrowser) Hiedi Utley (http://hiediutley.com/2011/03/30/phonegap-tutorial-series-4-using-a-third-party-plugin/)

I am basically trying to link to a child browser as you can see my link below... I have included all relevant files etc

I get the error message: "TypeError: childBrowser is undefined"




<script type="text/javascript" charset="utf-8" src="ChildBrowser.js"></script>
<script type="text/javascript" charset="utf-8">
var childBrowser;
function onBodyLoad()
{
document.addEventListener("deviceready",onDeviceReady,false);
}
/* PhoneGap has been initialized and is ready to roll */
function onDeviceReady()
{
var phoneGapReady;
phoneGapReady.innerHTML = "PhoneGap is Ready";
childBrowser = ChildBrowser.install();
}
function openChildBrowser(url)
{
try {
//both of these should work...
//window.plugins.childBrowser.showWebPage(url);
childBrowser.showWebPage(url);
}
catch (err)
{
alert(err);
}
}
</script>
<button onclick="openChildBrowser(\'http://www.google.com\')">Open Google</button>

Old Pedant
05-31-2012, 12:10 AM
OF COURSE!

Because you do this:


var phoneGapReady;
phoneGapReady.innerHTML = "PhoneGap is Ready";
childBrowser = ChildBrowser.install();

BUT YOU GET AN ERROR on the line in red!

YOU NEVER defined what in the banana pudding the variable phoneGapReady is supposed to point to!

So you tried assigning to the innerHTML of a null variable!

And when you get the error on the red line, you NEVER GET to the line that does the install!!

*********

And, please, do NOT double post!

Lerura
05-31-2012, 12:11 AM
What I understand from the tutorial page is, that ChildBrowser is a sub-plugin to Phonegap,
and thus also required a phoneGap.version.js in order to work, though obviously no direct error is thrown if ommited.

In your code your haven't called any version of PhoneGap.

Old Pedant
05-31-2012, 12:15 AM
Good catch, Lerura. Though that would then presumably give a different error message out of the ChildBrowser library code. The reason for the error he was getting is simply because he never was even calling the install function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum