scripting help

They have: 71 posts

Joined: Oct 2005

i would like to have a dialoge box pop up once the customer exits the page. so basicly if someone comes to one of my sites then tries to close the window there would be a dialoge box that comes up and says a little message...

are maybe ask is they would like to bookmark my site!

Danny G Guillory Jr
[email protected]
337.303.6453

Busy's picture

He has: 6,151 posts

Joined: May 2001

That's a very newbie thing to do, and apart from being really annoying for the user a lot of pop up blockers will block it anyway.

Don't give people a reason NOT to come back to your site. Don't try use all the bells and whistles because you can, use them ONLY if you need them, need not want.
Rule no. 1 KISS - Keep It Simple Silly

They have: 71 posts

Joined: Oct 2005

well i don't like the idea myself but its something that my boss wants on there sites...

Busy's picture

He has: 6,151 posts

Joined: May 2001

think it's onexit() (opposite to onload), but isn't browser compatible and doesn't always work.

Some info for your boss.
Asking if someone wants to bookmark the site is basically begging. if the content is there then people will bookmark it themselves.
People these days have folders of bookmarks, folders for different catagory of site - shopping, info, pc ...
Also think about the people returning to the site, they will get the pop up on leaving everytime, that's reason enough to stay away from your site, not return

They have: 71 posts

Joined: Oct 2005

yeah same thing i told the guy but het what do i know I"M JUST THE WEBMASTER!

They have: 71 posts

Joined: Oct 2005

thanks though, guess they will feel the affects wether its good are bad, just as long i i get my check! haha Smiling

Pleb's picture

They have: 11 posts

Joined: Jan 2006

Mmm. You might consider storing some info in the cookie & only displaying the pop-up on exit if it's not been seen/set before. Depending on your back-end you could also persist this info and set the appropriate cookie property on user login. That at least would cut down the annoyance to your repeat visitors.

As an aside (having had to attempt a similar feat before for the purpose of logging out a user when they exited an Intranet site), I must say that it's quite difficult to "plug up" all the exit points from you site & capture the appropriate events. Even in browsers that do support the event (IE), it seemed not to fire at least 20% of the time...

ITSweatshops.com
Technology Company Employee and Contractor Surveys

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.