重定向网址打开设备浏览器

时间:2018-10-26 06:53:25

标签: ionic-framework cordova-plugins

使用ionic 3中的浏览器插件,我只需要在ionic应用程序内打开浏览器网络视图,而无需打开外部浏览器,所以我确实喜欢这样

constructor(    public iab: InAppBrowser) {}
url = "https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/";

    options : InAppBrowserOptions = {'location':'no'    };

        this.iab.create(this.url,'_self' , this.options )

即使我将目标设置为“ _blank”,该链接也会在外部浏览器中打开

但是在某些设备中,URL是在浏览器中打开的,有人可以帮助我

1 个答案:

答案 0 :(得分:0)

HTML

<ion-content  >
   <iframe  sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts"  *ngIf="!loading" style="width:100%; height:100%; border:none; " [src]="yourURl"></iframe>
</ion-content>

将此行添加到构造函数中

 this.yourURl=this.sanitizer.bypassSecurityTrustResourceUrl(URL_link_here);
相关问题