In my journey with ionic version 1 (just starting out with ionic & angularjs), I encountered an issue while trying to close the in app browser upon reaching a specific URL. The problem arises from the fact that the event triggered on "loadstart" is of type MouseEvent, and as a result, I was unable to extract the URL information from the object, leading to an undefined error when using console.log(event.url). Additionally, I experimented with Loadstop and exit events in the listener without success.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
function onExit(event) {
var urlSuccessPage = "https://tick.com/s";
alert(event);
alert(event.url);
console.log(event.url);
console.log(event);
if (event.url == urlSuccessPage) {
inAppBrowser.close();
}
}
var inAppBrowser = window.open("https://tick.com", "_blank", "location=yes");
inAppBrowser.addEventListener('loadstart', onExit(event));
}