问题
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. :)
回答1:
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.
回答2:
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);
}
}
来源:https://stackoverflow.com/questions/47299642/webview-in-ionic-3