Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alert when user leaves your page.

Status
Not open for further replies.

CyClonenl

Programmer
Aug 31, 2005
3
NL
Hi, i have a question.
I want to show an alert message when people leave my page but not when they go to another section of my page, is there a script for?

Thanks in advance,
CyClonenl
 
This is what you need:

<body onunload="alert('Bye Bye!')">

That will say Bye Bye! when someone closes the window or navigates elsewhere

Hope thats what you need :)
 
This will also greatly annoy people. If you have a commercial site, be prepared to have visitors and potential customers NOT come back. If it's a personal site, you'll mainly just annoy your friends, and they'll stop coming to your page, too.

Lee
 
Just would like to further agree with trollacious and FesterSXS.

Nothing you can say in an alert would make me change my mind about leaving. Even something thanking me for visiting would likely be irritating.

Then again, you may be using you may be using it for some new and wonderful purpose that I haven't thought of. I hope so! :)

Mike
 
You guys are so pessimistic! Give the guy a break...

I bet he's coding a cool site that alerts a random person (as they leave the site) a secret special code that they can use to get a free tour of the Willie Wonker Chocolate Factory or something equally cool.

Yeah. That'd be about the only time I'd ever consider throwing an alert onunload.

[smile]
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
He'd probably need code so that it only does it 5 times, as there are only 5 tickets :(
 
My apologies! I'd give anything to get my hands on an everlasting gobstoppper...
 
Bank sites commonly do this, to let you know that you're leaving the cozy SSL confines of the site and are headed elsewhere. And to me, it's a perfectly legitimate message in that circumstance. Another use would be a kids site, where the content was all carefully monitored, but a link in a post or something could take them to a porn site or such.

It's possible he has a good use for it. Probably not, but it's possible.
 
More something like this.

"In our fight against internetaddiction, we are glad that you only stayed for 5 minutes at our site and hope you don't come back anytime soon."

or

"You have won 5 million dollars (If you see this message everytime you leave our site then there's something wrong with the javascript and you won't recieve the money)."



Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
or

"If you don't see this exit window your browser has probably turned javascript off. Turn it on so we can give you 5 million bucks."

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top