469,309 Members | 2,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,309 developers. It's quick & easy.

pop up a new window if user abandons a website.

Im needing a script that when a user clicks the "X" (closing the browser) or abandons my site a new small pop up window will appear..

The new small pop up window will ask "Why are you abandoning my site? Did you have any questions .. please let us know.." and then the user has the option to answer it or not.... then submit message or totally close the new window and main window..


I know the "window.closed" is the key but I dont know how to use it .. I checked on the internet but no information nor samples of it...

thanks..
Sep 11 '07 #1
5 1206
dmjpro
2,476 2GB
Im needing a script that when a user clicks the "X" (closing the browser) or abandons my site a new small pop up window will appear..

The new small pop up window will ask "Why are you abandoning my site? Did you have any questions .. please let us know.." and then the user has the option to answer it or not.... then submit message or totally close the new window and main window..


I know the "window.closed" is the key but I dont know how to use it .. I checked on the internet but no information nor samples of it...

thanks..
Welcome to TSDN.
Try this, it will work.

Expand|Select|Wrap|Line Numbers
  1. window.onbeforeunload = function(){/*Your code goes here*/}
  2.  
Good Luck!
But mind it, it will work in Opera.

Kind regards,
Dmjpro.
Sep 11 '07 #2
u can try something like this

Expand|Select|Wrap|Line Numbers
  1. window.onbeforeunload=function(){ 
  2. my_win=window.open("", "mywindow1","width=350,height=150");
  3. my_win.document.write(/*write ur code here*/)
  4. };
  5.  
Sep 11 '07 #3
acoder
16,027 Expert Mod 8TB
youtubers, just a word of warning. While the suggestion may work in most modern browsers, it is extremely annoying. If the user decides to leave your website, it's generally good practice to let them leave. If you don't and pester them with a popup, they are more than likely to abandon your website for good (never to return again).
Sep 11 '07 #4
the window.onbeforeunload event will be fired also when user refreshes the page
Sep 11 '07 #5
pbmods
5,821 Expert 4TB
Heya, Tubers.

Beware of popup blockers!

The average attention span of an internet User is maybe 5 seconds. If you're noticing a lot of unique-but-onetime visitors in your server logs, then your site has nothing that is 'grabbing' your Users' attention.

Direct feedback would be nice, but you're not going to get it that way.
Sep 11 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

60 posts views Thread by Fotios | last post: by
14 posts views Thread by Frances Del Rio | last post: by
20 posts views Thread by Geoffrey H. Goldberg | last post: by
2 posts views Thread by trialproduct2004 | last post: by
5 posts views Thread by James Coleman | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.