要在使用ionic开发的app中打开第三方应用,使用iframe来实现,查了一些资料,记录下来,免得忘记。
1、在config.xml中
<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
2、html
<ion-content > <iframe id="iframe" sandbox="allow-scripts allow-top-navigation allow-pointer-lock allow-same-origin allow-popups allow-forms" [src]="url" height="100%" width="100%" > </iframe> </ion-content>
3、ts中
引入DomSanitizer
import {DomSanitizer} from "@angular/platform-browser";
定义url,注意url是any,不是string
url:any;使用DomSanitizer对url做处理,
ionViewDidLoad() { // 使用DomSanitizer对url做处理 this.url = this.domSanitizer.bypassSecurityTrustResourceUrl('http://m.51job.com/search/jobsearch.php'); }