I need to catch closing tab/browser on mobile. onunload & onbeforeunload javascript event can catch refresh page, submit form, redirect page, close tab/browser... It worked perfectly on PC, but when I tried these events on mobile browsers (Chrome on Android, Safari on iOs). It can not catch closing tab/browser event. Please see my code below:
<script>
window.onunload = window.onbeforeunload = function (e) {
var e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
//window.open("http://www.w3schools.com");
return "Hello";
}
// For Safari
//window.open("http://www.w3schools.com/jsref/event_onunload.asp");
return "Hello";
};
</script>
<?php echo "Test onunload and onbeforeunload event"; ?>
Could you please advise?
Thanks