Issue
My app which is built on ionic has an inapp browser that opens a url. This works fine.
I need to identify when and if the user clicks the close/”X” button on it to run a function.
I have tried the exit eventlistener but it is not fired when the browser is closed.
I have tried the below.
var ref = window.open($scope.url, '_blank');
then
ref.addEventListener('exit', $scope.bclose());
$scope.bclose = function(){
alert('Close');
}
also
ref.addEventListener('exit', function(event) {
alert('Browser Closed');
});
I however have a loadstop listener which works fine.
Any help is greatly appreciated.
Solution
Try to use following way. It is working fine.
$scope.openLink = function (url) {
var ref = cordova.InAppBrowser.open(url, '_blank', 'location=yes');
ref.addEventListener('exit', function(){
alert('exit');
});
}
I am using following cordova inappbrowser version in my config.xml
<plugin name="cordova-plugin-inappbrowser" src="https://github.com/apache/cordova-plugin-inappbrowser.git" version="1.4.1-dev" />
Answered By – coder
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0