Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 10-05-2011, 03:45 PM Window.close()
Skilled Talker

Posts: 96
Name: Joan
Trades: 0
hello guys,

i'm not sure if there's a way to do this or not..

HTML Code:
<script type="text/javascript>
window.onbeforeunload = askConfirm;
function askConfirm(){
                return "Are you sure you want to leave this page? Please close it by saving notes or clicking Send!";
                }
</script>
this is what i have so far and it works when the user tries to close the window the alert will appear. My questions is when they click the button save the window closes by itself but the alert will still pop up or when they send the info the window is supposed to close by itself but still the alert will pop up.. now is there a way to apply this askConfirm only when they close the window by clicking the X in the corner?

Thanks

Last edited by stivens; 10-05-2011 at 03:48 PM..
stivens is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-05-2011, 05:44 PM Re: Window.close()
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you need to have your routine stop the event "bubbling" by having it return false to the calling event.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-05-2011, 05:58 PM Re: Window.close()
Skilled Talker

Posts: 96
Name: Joan
Trades: 0
Quote:
Originally Posted by chrishirst View Post
you need to have your routine stop the event "bubbling" by having it return false to the calling event.
I really don't know much about JS, is this complicated to do? how would i do that??
stivens is offline
Reply With Quote
View Public Profile
 
Old 10-05-2011, 06:23 PM Re: Window.close()
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.quirksmode.org/js/introevents.html

http://www.quirksmode.org/js/events_order.html
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Window.close()
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19301 seconds with 12 queries