1

I have my one blog which i want to convert into ionic app. I use InAppBrowser plugin but the problem is when i press the back button it will come to my default ionic home page.

i follow the below steps :

ionic start myblog

ionic platform add android

ionic cordova plugin add cordova-plugin-inappbrowser

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

and then added provider in app.module and in home.ts write the following.

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

constructor(private iab: InAppBrowser) { }


...


const browser = this.iab.create('https://ionicframework.com/','_self','location=no');
browser.show();

Also location=no is not working. Like android ionic provide the webview ?? can anyone help me out ? any help is appreciated. :)

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
Foram Sangani
  • 287
  • 1
  • 4
  • 17

2 Answers2

5

Simple and sort solution from the my github repo

in home.html

<iframe  height="100%" width="100%" [src]="urlpaste()"></iframe>

and in home.ts

import { Component } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  url: any;
  constructor(private sanitize: DomSanitizer) {}
  urlpaste(){
    this.url = "https://hackerrankgeek.wordpress.com/";
    return this.sanitize.bypassSecurityTrustResourceUrl(this.url);
  }
}
Jaydeep Kataria
  • 817
  • 10
  • 22
Kishan Oza
  • 1,707
  • 1
  • 16
  • 38
3

In simpleway without installing any plugin u can use tag inside which define url of your's blog. e.g In home.ts :

    import { DomSanitizer } from '@angular/platform-browser';
    url: any;
    constructor(private sanitize: DomSanitizer){
    this.url = sanitize.bypassSecurityTrustResourceUrl("YOUR_URL");
    }

and in home.html :

<iframe  height="100%" width="100%" [src]="url" name="iframe_a"></iframe>

Try this.

Kishan Oza
  • 1,707
  • 1
  • 16
  • 38
Husain
  • 579
  • 2
  • 15