如何在Phonegap 3.0中的InnApp浏览器中获取当前URL [英] How to get current url in InnApp browser in Phonegap 3.0

查看:107
本文介绍了如何在Phonegap 3.0中的InnApp浏览器中获取当前URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在单击关闭按钮的同时(在加载某些URL之后的任何时间)检索inapp浏览器的当前URL,我的代码如下所示

Hi i cannot able to retrieve current url of inapp browser while click close button (OR at any time after loading some url) , my code given bellow

 var ref = window.open('http://google.com', '_blank', 'hidden=yes');
 ref.show();
 ref.addEventListener('exit', function(event) {

          alert(JSON.stringify(event));  // no data related to URL
 });

 ref.addEventListener('loadstop', function(){
    alert(window.location.href); // always get local address ie File:/// ....
  }); 

请帮助我.我发现了这个 SO问题,但没有得到任何答案

please help me. i fount This S O question but didn't get any answer

推荐答案

根据PhoneGap的文档,此处 http://docs.phonegap.com/en/2.3.0/cordova_inappbrowser_inappbrowser.md.html ,您应该能够获得如下网址:

According to PhoneGap's documentation here http://docs.phonegap.com/en/2.3.0/cordova_inappbrowser_inappbrowser.md.html you should be able to get the url like this:

ref.addEventListener('loadstop', function() { alert('stop: ' + event.url); });

我不认为您可以从退出事件访问URL,但可以在loadstop事件期间将其存储在全局变量中,然后在退出事件中查看它.

I don't believe you can access the url from the exit event but you could store it in a global variable during the loadstop event then view it in the exit event.

这篇关于如何在Phonegap 3.0中的InnApp浏览器中获取当前URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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