Open an External Link in Safari (Cordova)

Open an external link in Safari (cordova)

You can embed javascript code in the href attribute. This should do the trick:

<a href="javascript: window.open('http://www.sdtaproom.com/', '_system'); return false;">Visit Website</a>

You will also have to install the InAppBrowser plugin (don't be fooled by its name).

PhoneGap: Opening external URL's in Safari

Had the same problem after upgrading to Cordova 1.6.1.

Try adding
target="_blank"
to your links.

That did the trick for me.

How to open a href link outside cordova webview (in Safari or Google Map)?

This is pretty simple to do, try to open it as if you open the link in a new tab. Just add this attribute to your code:

target="_blank"

So, you have:

<a href=""https://maps.google.com/?q=" + myAddressString target="_blank"> Address URL </a>

Cordova 3.0 - Open link in external browser in iOS

NOTE: to make window.open('somelink', '_system') to work you now need a device-level plugin, the inAppBrowser. Here are the installing instructions as of Cordova 3.0

From the Docs for 3.0:

As of version 3.0, Cordova implements device-level APIs as plugins. Use the CLI's plugin command, described in The Command-line Interface, to add or remove this feature for a project:

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
$ cordova plugin rm org.apache.cordova.core.inappbrowser

These commands apply to all targeted platforms, but modify the platform-specific configuration settings described below:

iOS (in config.xml)

<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>

I just tested this and it works.

Using Cordova, how can I open external URLs in Chrome, instead of the in-app browser?

Just going back through old questions and marking them as answered. I ended up doing this:

function onDeviceReady() {
return $(document).on('click', 'a[target="_blank"]', function(e) {
e.preventDefault();
return window.open(this.href, '_system');
});
};

if (!!window.cordova) {
document.addEventListener('deviceready', onDeviceReady, false);
}


Related Topics



Leave a reply



Submit