473,387 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1274
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

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

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
6
by: Tony G. | last post by:
Hi there, I have an APS 3 application, running on a Windows 2003 Web edition server - it is a very busy website, and when users are click on certain links (membership info), a new window i...
14
by: Frances Del Rio | last post by:
I'm trying to open a url in a new window while pg loads (but NOT in a pop-up..) I need to do sthg like // while pg is loading.. window.location ='page.html' // but I need this to open in a...
4
by: ...D. | last post by:
OK. I am halfway decent with HTML. Now I want to try javascript for some things that HTML cannot do. I have looked over a tutorial & all. What I want to do is create a button, that when...
20
by: Geoffrey H. Goldberg | last post by:
I have made a remote control window which opens from its parent. On loading, the remote is positioned relative to the screen using window.moveTo(x,y). What I would like to happen is the remote...
2
by: trialproduct2004 | last post by:
Hi all i am having problem in html page. I have two html page one containing link to other. I am using href to display new page and using target as _blank. I want to open new page in maximized...
4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
5
by: James Coleman | last post by:
I have to send a user to a 3rd party site. Basically I am thinking I need a linkbutton with an onclick event. The even handler would populate the necessary values (userid, encryptedid, usergroup)...
6
by: mistral | last post by:
what is correct way open a PDF document in new window use hyperlink? I want show images thumbnails linked with PDF files, when click on thumbnail, PDF will be opened in new window. Some of PDF...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.