如何在退出事件InAppBrowser,Ionic2上获取当前URL [英] how to get current url, on exit event InAppBrowser, Ionic2

查看:195
本文介绍了如何在退出事件InAppBrowser,Ionic2上获取当前URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个解决方案,在该解决方案中,需要在InAppBowser Ionic2的退出事件上获取当前网址.

I am trying to implement a solution where I need to get the current url on exit event of InAppBowser Ionic2.

我的代码是

import { Component } from '@angular/core';

import { NavController, NavParams } from 'ionic-angular';
import {InAppBrowser} from 'ionic-native';


@Component({
  selector: 'page-list',
  templateUrl: 'list.html'
})
export class ListPage {
  browser:any;
  exit:boolean = false;
  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  startPayment(){
    this.browser = new InAppBrowser('https://ionic.io', '_blank','location=no,toolbar=no,hardwareback=no,EnableViewPortScale=yes,closebuttoncaption=Done');
    this.browser.on("exit")
            .subscribe(
            (e) => {
                this.checkpaymentStatus(e);
            },
            err => {
                console.log("InAppBrowser loadstart Event Error: " + err);
            });
  };

  checkpaymentStatus(e){
    console.log(e);
    console.log("in app browser exit")
    this.exit = true;
  }    
};//

exit事件正常触发,但是我无法在事件(e)中获取url,它只是提供了Object {type:exit}.

The exit event is firing properly but I am unable to get the url in event(e), it just gives Object{type:exit}.

请告诉我,如何在退出时获取网址. 谢谢

Please tell me , how can I get the url on exit. Thanks

推荐答案

只需使用e.url

checkpaymentStatus(e){
    console.log(e.url); // you will get url here
    // ... ... ...
}    

这篇关于如何在退出事件InAppBrowser,Ionic2上获取当前URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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