phonegap open link in browser

ahsan ali picture ahsan ali · Jul 26, 2013 · Viewed 174.9k times · Source
<a target="_blank" data-rel="external" href="http://www.kidzout.com">www.kidzout.com</a>

hey experts i am using phonegap 2.9.0 and i am using the above code to open the link in the browser but it opens it in the same app...... how to open it safari browser?

it opens the website in the same app and then i am unable to come back to the app, so i need to delete the app and install that again.....

Answer

freejosh picture freejosh · Jul 26, 2013

As suggested in a similar question, use JavaScript to call window.open with the target argument set to _system, as per the InAppBrowser documentation:

<a href="#" onclick="window.open('http://www.kidzout.com', '_system'); return false;">www.kidzout.com</a>

This should work, though a better and more flexible solution would be to intercept all links' click events, and call window.open with arguments read from the link's attributes.

Remember you must install the InAppBrowser plugin for this to work:

cordova plugin add cordova-plugin-inappbrowser