Categories
Development

Opening Links in System Browser with Cordova 2.4.0 (PhoneGap)

Found myself a little stumped on this one. I’m making a simple directory mobile app using PhoneGap for iOS and Android. The listings have a website associated with them that we want to link to from the mobile app.

However, when I tested it on my iPhone I discovered that all the links were opening up within the app iteslf. Meaning that user was now trapped in that site with no way back to the Mobile App. Not a very usable experience (though the business clicked on in this case may’ve liked that).

So I tried many things, target=”_blank” seemed to be recommended. Apparently that worked on older versions of Cordova. But, not in my case.

After some more research I did find some documentation on how to handle the InAppBrowser. Finally, exactly what I was looking for!

Apparently you have to use the window.open() function and set the target to _system.

window.open('http://a-website.com', '_system');

So, I updated my links and all seems to be well now!


Leave a Reply

Your email address will not be published. Required fields are marked *