I try to invoke the native browser in ionicframework to open a url without plugin.
the code:
if(ionic.Platform.isAndroid()) {
navigator.app.loadUrl(url, {openExternal : true});
}else if(ionic.Platform.isIOS()) {
window.open(url, '_system');
}
In fact, app can invoke the browser in Android, but in ios, it will replace the current app view instead of open the browser.
Please suggest.
You just need to do something like this, looks like your device was not ready:- Please use below given function (requires phonegap.js)
if(ionic.Platform.isIOS()) {
{
// Wait for Cordova to load
document.addEventListener('deviceready', onDeviceReady, false);
// Cordova is ready
function onDeviceReady()
{
// open URL in default web browser
var ref = window.open(encodeURI(url), '_system', 'location=yes');
}
}
Below is some details regarding window.open function
url: The URL to load (String). Call encodeURI() on this if the URL contains Unicode characters. var ref = window.open(url, target, options);
Target: 2nd parameter can be following :
_self: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in the InAppBrowser.
_blank: Opens in the InAppBrowser.
_system: Opens in the system's web browser.
options: Options for the InAppBrowser. Optional, defaulting to: location=yes. (String)
The options string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. All platforms support the value below:
location: closebuttoncaption: clearcache: clearsessioncache: