Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open external links from my Ionic app inside a web browser view

Step 1 : Ionic create New App. (ionic start myApp1 sidemenu)

Step 2 : Create New Page home and aboutus. (ionic generate page aboutus)

step 3 : Create button at aboutus page for url redirect to another website.

aboutus.html : (<button ion-button (click)="redirect()"> GO » <button>)

aboutus.ts : redirect() { window.open("https://www.w3schools.com/php/", "_self"); }

step 4 : When i click GO button the url redirect to w3schools.com and again browser back button click the redirect to home page only. i need redirect to aboutus page. help me any one.

like image 830
Myl Swamy Mca Avatar asked May 11 '18 04:05

Myl Swamy Mca


1 Answers

Use it In App Browser Ionic Native plugin

Install the Cordova and Ionic Native plugins:

ionic cordova plugin add cordova-plugin-inappbrowser

npm install --save @ionic-native/in-app-browser

In app.module.ts add InAppBrowser Provider

import { InAppBrowser } from '@ionic-native/in-app-browser';

providers: [
  InAppBrowser,
]

Html:

 <ion-buttons>
    <button ion-button (click)="redirect()"> GO » <button>
 <ion-buttons>

In ts:

import { InAppBrowser } from '@ionic-native/in-app-browser';


 constructor(private inAppBrowser: InAppBrowser) {}

redirect() {
 this.inAppBrowser.create("https://www.w3schools.com/php/");
}

you can also see this video tutorial

like image 55
Gurbela Avatar answered Sep 21 '22 17:09

Gurbela