ionic-framework - 重定向 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”,链接也会在外部浏览器中打开
但是在某些设备中,网址会在浏览器中打开,有人可以帮我吗
解决方案
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);
推荐阅读
- python - 如何计算numpy数组元素?
- javascript - 将多行动态添加到数据表
- architecture - PyQt 应用程序的高级结构 - 拆分为模块并传递变量
- mysql - 存储过程输出返回 null
- oracle-apex - Oracle APEX表单上表,通过表单更改值后不要重置表分页
- c# - 如何实现动态加载新产品的工厂模式(开闭原则)?
- ar.js - 基于位置的 ARJS 示例不断显示警报('无法检索 GPS 位置。信号不存在。')
- python - Scrapy 响应 url 与我在启动 url 上定义的不完全一样
- python - Dask Dataframe 中的 Groupby、Unstack 和 Plot
- javascript - 无法重现错误:没有“新”就无法调用类构造函数 DateTimeFormat