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
Track Browser Window Closing Via Javascript?
Old 10-22-2008, 09:04 AM Track Browser Window Closing Via Javascript?
Super Talker

Posts: 148
Trades: 0
Hi all,

I am trying to find out what ways there are to find out the window browser is closing. For example, you could click on the "X" on the top right of your window, you could press alt + f4 keys together and you could also right-click and close on your task on the taskbar below.

So how do you track ight-click and close on your task on the taskbar below? I could use the body onunload, but it also detects when i refresh the page or move to another page. I only want to clear an element when the window browser is closed. Any suggestions? Thanks!
shaoen01 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-22-2008, 09:54 AM Re: Track Browser Window Closing Via Javascript?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
window.onclose event
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I 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-22-2008, 10:32 AM Re: Track Browser Window Closing Via Javascript?
Super Talker

Posts: 148
Trades: 0
I don't think there is window.onclose event
shaoen01 is offline
Reply With Quote
View Public Profile
 
Old 10-22-2008, 10:41 AM Re: Track Browser Window Closing Via Javascript?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
https://developer.mozilla.org/en/DOM/window.onclose
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I 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-22-2008, 11:02 AM Re: Track Browser Window Closing Via Javascript?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Can you stop the window from closing with window.onclose=function(){return false;} ?
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 10-22-2008, 11:14 AM Re: Track Browser Window Closing Via Javascript?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Never tried it, but you can be very annoying with window.onblur = self.focus
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I 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-22-2008, 12:56 PM Re: Track Browser Window Closing Via Javascript?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
How about this?
Code:
window.onunload=function() {
function dontLeave() {
    if(confirm("Please dont leave")) {
        dontLeave();
    } else {
        dontLeave();
    }
}
dontLeave();
}
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Track Browser Window Closing Via Javascript?
 

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.25450 seconds with 12 queries