Search code examples
ionic3ionic-native

How to open webview not by chrome browser but by ionic


My code is as below. I want to open google.com not on Chrome or basic browser but open on Ionic native I changed the second parameter to _self, _blank, _system and Ionic Cordova ran the Android to check on my device, but whenever I came to the place, it ask me to open on Chrome or other browser and if I click one browser, it open it on that browser.

How can I open web site on Ionic?

constructor(public navCtrl: NavController,public navParams : NavParams,
  public modalCtrl:ModalController,private iab:InAppBrowser
   public fb:FirebaseService) {
    const options:InAppBrowserOptions={
      location:'no',
      fullscreen:'yes'
    }
    const browser = this.iab.create('https://google.com','_system',options);

Solution

  • As you already mentionend, the second parameter should be changed to _blank to open the link inside ionic:

      openWithInAppBrowser(): void {
        const browser = this.iab.create('https://google.com', '_blank');
      }
    

    If that is not going to work, please verify if you installed the plugin correctly:

    • ionic cordova plugin add cordova-plugin-inappbrowser
    • npm install --save @ionic-native/in-app-browser.

    If you need more help, please post the whole code and your ionic environment info (ionic info).