JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 5th, 2012, 10:56 PM
beebac beebac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2011
Posts: 107 beebac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
Onbeforeunload not work on mobile browser? Any alternative?

Hi. I've a js confirm message if a user want to leave the page. It work on pc browser but when I try to use it on mobile safari it doesn't work. And I can't find any thing from the internet. There're only a little in the net but those doesn't have a firm solution. It's more a suggestion to give a try but it's no use.

Anyone know any alternative? Thank you.


window.onbeforeunload = askUser ;
function askUser(){
return "Are you sure to exit?";
}

Reply With Quote
  #2  
Old November 6th, 2012, 02:59 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 601 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 25 m 38 sec
Reputation Power: 69
You might want to use "window.unload" for Safari, instead of "window.onbeforeunload".

iOS Developer Library - Safari Handling Events

Then, if needed; you might be able to use the abort() event; to prevent propagation.

Reply With Quote
  #3  
Old November 6th, 2012, 09:29 PM
beebac beebac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2011
Posts: 107 beebac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
I tried this. I did a alert or open inside and no respond. Any idea?

$(window).unload(function() {
window.open("http://www.google.ca");
});

Quote:
Originally Posted by web_loone08
You might want to use "window.unload" for Safari, instead of "window.onbeforeunload".

iOS Developer Library - Safari Handling Events

Then, if needed; you might be able to use the abort() event; to prevent propagation.

Reply With Quote
  #4  
Old November 6th, 2012, 09:49 PM
beebac beebac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2011
Posts: 107 beebac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
I can do onunload but I can't do abort. It seems doesn't work. My main goal is to do confirm message and if they cancel then it won't leave the page. I'm just trying to do abort but not work. Even window stop() seem not work.

window.onunload=function() {
window.abort();
}


Quote:
Originally Posted by web_loone08
You might want to use "window.unload" for Safari, instead of "window.onbeforeunload".

iOS Developer Library - Safari Handling Events

Then, if needed; you might be able to use the abort() event; to prevent propagation.

Reply With Quote
  #5  
Old November 7th, 2012, 01:45 AM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 601 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 25 m 38 sec
Reputation Power: 69
Did you try something like this?

Code:
window.onunload = function() {
return confirm("Are you sure you want to leave this page?");
}


Because according to the Safari Web Content Guide; Safari iOS supports JavaScript dialog methods; such as: alert, confirm, print, and prompt.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Onbeforeunload not work on mobile browser? Any alternative?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap