如何在Web浏览器视图中从我的Ionic应用程序打开外部链接 [英] How to open external links from my Ionic app inside a web browser view

查看:417
本文介绍了如何在Web浏览器视图中从我的Ionic应用程序打开外部链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第1步:Ionic创建新应用程序。 (离子启动myApp1 sidemenu)

Step 1 : Ionic create New App. (ionic start myApp1 sidemenu)

第2步:创建新页面主页和aboutus。 (离子生成页面aboutus)

Step 2 : Create New Page home and aboutus. (ionic generate page aboutus)

步骤3:在aboutus页面创建按钮,以便url重定向到另一个网站。

step 3 : Create button at aboutus page for url redirect to another website.

aboutus.html :(< button ion-button(click)=redirect()> GO»< button>)

aboutus.html : (<button ion-button (click)="redirect()"> GO » <button>)

aboutus.ts:redirect(){window.open( https:// www.w3schools.com/php/ ,_ self); }

aboutus.ts : redirect() { window.open("https://www.w3schools.com/php/", "_self"); }

步骤4:当我点击GO按钮时,网址重定向到w3schools.com,再次浏览器返回按钮,只需点击重定向到主页。我需要重定向到aboutus页面。帮助我任何人。

step 4 : When i click GO button the url redirect to w3schools.com and again browser back button click the redirect to home page only. i need redirect to aboutus page. help me any one.

推荐答案

使用在应用程序浏览器中 Ionic Native插件

Use it In App Browser Ionic Native plugin

安装Cordova和Ionic Native插件:

Install the Cordova and Ionic Native plugins:

ionic cordova plugin add cordova-plugin-inappbrowser

npm install --save @ionic-native/in-app-browser

在app.module.ts中添加InAppBrowser提供商

import { InAppBrowser } from '@ionic-native/in-app-browser';

providers: [
  InAppBrowser,
]

Html:

 <ion-buttons>
    <button ion-button (click)="redirect()"> GO » <button>
 <ion-buttons>

在ts:

import { InAppBrowser } from '@ionic-native/in-app-browser';


 constructor(private inAppBrowser: InAppBrowser) {}

redirect() {
 this.inAppBrowser.create("https://www.w3schools.com/php/");
}

您还可以看到 视频教程

you can also see this video tutorial

这篇关于如何在Web浏览器视图中从我的Ionic应用程序打开外部链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆