Reputation: 389
I want to open external URL in a system browser. I have the following code which work on Android, but not on iOS. on iOS simply nothing happens, no errors in the console, etc.
<button ion-item href="#" onclick="window.open('https://www.instagram.com/pagetopen/', '_system');">
I don't have the inAppBrowser plugin installed, I don't want inapp but the system browser. Do I have to install inApp browser to open URLs in system browser? I'd rather avoid installing it if possible.
How can I get this to work? Thanks!
Upvotes: 0
Views: 2657
Reputation: 389
Got this to work. InAppBrowser is needed in iOS. Just installing the plugin allows the window.open to work. No need to use inAppBrowser itself. In Android this works without the plugin.
thanks
Upvotes: 2
Reputation: 1226
You do need to install the Cordova inappbrowser for this to work on iOS. Because you are passing '_system'
in your window.open
call, you will get the link opening in the system browser, despite the plugin name "inappbrowser".
Upvotes: 0
Reputation: 6421
As far as i know you don't have access to the window object in your template, you need to create a method in your class and use it in your click, also, use (click)
instead of onclick
.
On HTML:
<button ion-item href="#" (click)="openURL()">
On .ts:
openURL = () => {
window.open('https://www.instagram.com/pagetopen/', '_system');
}
Upvotes: 0