phonegap/phonegap-plugins — Issue #308: ChildBrowser onClose and onLocationChange Not Working - Uncaught TypeError - Android
Author: freeman0189
Created: 2012-01-03 09:40:59+00:00
State: open

I am having trouble with the onClose and onLocationChange callback functions. The handler I define isn't getting called and I'm getting the following errors:
"Uncaught TypeError: Cannot read property 'onClose' of undefined at file:///android_asset/www/step-three.html:41"
"Uncaught TypeError: Cannot read property 'onLocationChange' of undefined at file:///android_asset/www/step-three.html:42"

I'm using PhoneGap 1.3 on Android. My javascript code is below:

$(document).ready(function() {
$('#foursquare-connect-btn').click(function() {
//openChildBrowser($(this).attr('href'));
window.plugins.childBrowser.showWebPage('http://www.google.com/', { showLocationBar: true });
return false;
});
window.plugins.childBrowser.onClose = childBrowserClosed();
if (typeof window.plugins.childBrowser.onLocationChange !== "function") {
window.plugins.childBrowser.onLocationChange = function(loc) {
/*if (loc.indexOf("http://app.drinksync.mobi/foursquare/token") >= 0)
{
closeChildBrowser();
makeToast(loc, true);
}
else
{
closeChildBrowser();
makeToast('fail', false);
}*/
//alert(loc);
window.plugins.childBrowser.close();
};
}
});