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
Display Message on Close or Back Button
Old 10-31-2008, 06:57 PM Display Message on Close or Back Button
Novice Talker

Posts: 11
Name: Alex
Trades: 0
Hi everyone,

I'm looking to display a message when someone visiting one of my pages closes their browser window or hits their back button, but I don't want a message to display if someone clicks a link on my page.

Is there any way to accomplish this?

Thanks!
pico204 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-31-2008, 09:35 PM Re: Display Message on Close or Back Button
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.webmaster-talk.com/javasc...avascript.html
__________________
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 offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-05-2008, 09:33 PM Re: Display Message on Close or Back Button
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
Probably your best bet would be
document.Onunload="alert('No! Don't leave me')";

Does that work?
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
Old 11-06-2008, 01:43 AM Re: Display Message on Close or Back Button
Average Talker

Posts: 25
Trades: 0
window.onbeforeunload
__________________
Impossible means I'm possible.
softhink is offline
Reply With Quote
View Public Profile
 
Old 11-06-2008, 05:20 AM Re: Display Message on Close or Back Button
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
onbeforeunload and onunload will also trigger when the browser is going to a DIFFERENT page
__________________
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 offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Display Message on Close or Back Button
 

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