Click here to Skip to main content
15,885,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
beforeunload
and on
beforeunload
works fine in normal browser in desktop but the same does not work in iphone/ipad

i tried this from stackoverflow

var isOnIOS = navigator.userAgent.match(/iPad/i)|| navigator.userAgent.match(/iPhone/i);
var eventName = isOnIOS ? "pagehide" : "beforeunload";

window.addEventListener(eventName, function (event) { 
    
    ...
} );


this also does not detect browser/tab close

is there a way i can detect it in ipad/iphone

i am using it in asp.net

What I have tried:

var isOnIOS = navigator.userAgent.match(/iPad/i)|| navigator.userAgent.match(/iPhone/i);
var eventName = isOnIOS ? "pagehide" : "beforeunload";

window.addEventListener(eventName, function (event) {

...
} )
Posted
Updated 14-Apr-16 17:27pm

1 solution

I know
JavaScript
navigator.platform === 'iPad'

I know
JavaScript
navigator.platform === 'iPhone'


navigator.platform detect the platform you using in javascript
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900