Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question ChildBrowser + Cordova 1.7 errors please help - not an object

    Hi, I am trying to follow this tutorial:
    PhoneGap Tutorial Series – #4 Third-Party Plugins (ChildBrowser) Hiedi Utley

    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"

    Code:
    	<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>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,027
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    OF COURSE!

    Because you do this:
    Code:
                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!
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    946
    Thanks
    0
    Thanked 129 Times in 128 Posts
    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.
    Last edited by Lerura; 05-31-2012 at 12:32 AM.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,027
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •