4
votes

I am trying to open a link in the native browser or other external browser from my app, but I can only get it to open an in app browser.

I have the inappbrowser installed as specified here:

cordova.apache.org/docs/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html#window.open

I call the browser window like this: window.open("http://yourmindandmedia.com", '_system');

the result is the same as if I do this: window.open("http://yourmindandmedia.com", '_blank');

When I hit the device back button, my app is all washed out displaying no graphics and supporting no events. I've tried this as well:

navigator.app.loadUrl("yourmindandmedia.com", { openExternal:true });

to the same results.

These examples are done in Android environment, but I will be implementing in iOS as well. Ideally, the solutions are identical.

Thanks in advance.

1

1 Answers

4
votes

Here's the code I'm using until cordova works as before. As you can see it's a method you already tried. Try cordova plugin -l to make sure you've got the inappbrowser. I installed via: cordova plugin add org.apache.cordova.inappbrowser which is a bit different than the older instructions.I'm using Cordova V3.2 .

 window.onclick = clickEvent;

function clickEvent(e){
    e = e || window.event;
    var t = e.target || e.srcElement
    if ( t.name || t.href ){
       if( typeof t.href == "string" && t.href.substr(0,4) == 'http' ){
           if( t.attributes.href.value !== "#" ){
               window.open(t.href, '_system', 'location=yes');
           }
           return false; // no further action for this click
       }
    }
    return true; // process click as normal
}

I originally had navigator.app.loadUrl() but it seems to be specific to Android.