None of these answers are explicit enough to get external links to open in each platform. As per the inAppBrowser docs:
Install
cordova plugin add cordova-plugin-inappbrowser
Overwrite window.open (optional, but recommended for simplicity)
window.open = cordova.InAppBrowser.open;
If you don't overwrite window.open
, you will be using the native window.open
function, and can't expect to get the same results cross-platform.
Use it to open links in default browser
window.open(your_href_value, '_system');
Note that the target for the inAppBrowser (which is what the plugin name suggests it is to be used for) is '_blank'
, instead of '_system'
.
Without the steps above, I was not able to get links to open in the default browser app cross-platform.
Extra credit
Here's an example (live) click handler for the links:
document.addEventListener('click', function (e) {
if (e.target.tagName === 'A' &&
e.target.href.match(/^https?:\/\//)) {
e.preventDefault();
window.open(e.target.href, '_system');
}
});