How to get current url in InnApp browser in Phonegap 3.0

最后都变了- 提交于 2019-12-13 21:44:13

问题


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:/// ....
  }); 

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/18402508/how-to-get-current-url-in-innapp-browser-in-phonegap-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!