简体   繁体   中英

Prompt when attempting to close browser tab/window in Safari ios on iPad

I'd like to prompt my user after they attempt to navigate away from my webpage (it's a form) to confirm that they would like to leave. ie User attempts to close browser tab/window, user gets a pop up stating "Are you sure you want to leave? Some of your data may not have been saved." I see code on stackoverflow that works for IE, Firefox, Chrome, etc. browsers, but none of it works on Safari ios for iPad. Thanks in advance.

check like this:

var p=prompt('what dya say?',' ');
if(!p)// cancel was *probably* clicked
else if(p===' ')//ok was clicked with no input
else// 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM