Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top