首页 > 解决方案 > 重定向 url 打开设备浏览器

问题描述

在 ionic 3 中使用浏览器插件,我只需要在 ionic 应用程序中打开浏览器 Web 视图,而不是打开外部浏览器,所以我确实喜欢这个

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”,链接也会在外部浏览器中打开

但是在某些设备中,网址会在浏览器中打开,有人可以帮我吗

标签: ionic-frameworkcordova-plugins

解决方案


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);

推荐阅读