luQ
luQ

Reputation: 529

Cordova 2.3 Opening external Links

Im searching the web for hours now, tried probably all of the million answers out there regarding this topic... but unfortunately there wasnt a solution among them. So...

Update:

Is there a proper way to open external urls in Phonegap Version 2.3 without using a plugin?

There are a lot of solutions for lower versions than 2.3 out there, but non of them actually did the trick.

Thx.

Upvotes: 1

Views: 114

Answers (1)

luQ
luQ

Reputation: 529

It seems that Cordova is already providing a solution for my problem in version 2.3.

This makes plugins like ChildBrowser obsolete.

The answer is InAppBrowser

check the following links:

stackoverflow

and the doku:

official doku

Make sure to implement this at the right spot. In my case it was a element of a listview. I implemented it like this:

$(document).bind("mobileinit", function(){


...


$('.listviewmain').delegate('li', 'tap',  function(event, ui, e) {

var index = $(this).closest('li').index();  


if(result.news[index].id == "ads") {   

var ref = window.open('http://google.com', '_blank', 'location=no');

// attach listener to loadstart
ref.addEventListener('loadstart', function(event) { 
    var urlSuccessPage = "http://myloginapp/success/";
    if (event.url == urlSuccessPage) {
    ref.close();    
    }
});
} 

...

}

Hope this helps :)

Upvotes: 1

Related Questions