Search code examples
ioscordovachildbrowser

PhoneGap/Cordova: childBrowser plugin giving strange URL (iOS)


I am having a great deal of difficulty getting the childBrowser plugin to work

Currently when I click my link it does nothing on my iOS simulator and when I click it using a browser I get a Web Page Not Found error with the web address looking something like:

file://myapp/www/%C3%A2%E2%82%AC%C2%9D#ᅢᄁ¬ツᆲᅡン

I am really stuck for ideas on whats going on and what is causing this, any advice would be greatly appreciated.

My code is:

<script type="text/javascript" charset="utf-8" src="js/ChildBrowser.js"></script>
        <script>
            function onDeviceReady() {
                childbrowser = ChildBrowser.install();
                var root = this;
                cb = window.plugins.childBrowser;

                if(cb != null) {
                    cb.onLocationChange = function(loc){ root.locChanged(loc); };
                    cb.onClose = function(){root.onCloseBrowser(); };
                    cb.onOpenExternal = function(){root.onOpenExternal(); };
                    //cb.showWebPage(“http://google.com”);
                                   }
                                   }

                                   function onCloseBrowser() {
                                   console.log(“onCloseBrowser!”);
                                   }

                                   function locChanged(loc) {
                                   console.log(“locChanged!”);
                                   }

                                   function onOpenExternal() {
                                   alert(“onOpenExternal!”);
                                   }        

<body onLoad=”onBodyLoad()”>
<a href=”#” onclick=’cb.showWebPage(“http://www.google.com”);’>Click Me</a>

Solution

  • It is difficult to get which part of the app is doing wrong as given source is not enough. I have a small demo application which just uses childbrowser with cordova 1.7.0 which you can check to make sure the source is unaltered.

    ios-cordova-childbrowser example