views:

651

answers:

3

My company creates web surveys and once in a while I get asked if we can do an exit survey on a website. So when a visitor is about to leave the site a "popup" appears asking if they'd take a quick survey. By "popup" I'm referring to a floating CSS div, not a child window (although sometimes clients don't realise this).

Is it technically possible to code a genuine exit survey?

I don't think so but am I missing something? The onbeforeunload event is close to the functionality required but the message and buttons aren't fully customiseable to make it usable.

The current trend for implementing an exit survey is to popup an invite at the start of the visit, and if the user says ok then a child window is opened and focus set back to the main window. At the end of the visit the users sees the child window. I swear I've never seen a "popup on exit" survey (unless by coincidence).

+1  A: 

Surely they 'exit' the site by closing the window/tab? You're asking for a way to prevent them closing the tab? Or popup a window triggered by the close action? That sounds like it would be prevented by the browser for good reason, and if you found a workaround it would be likely to be fixed in future versions.

Colin Pickard
I agree. I've had this conversation with a couple of non-programmers more than once. We can display a survey invite anywhere on a website, but we can't display it at the instant the user chooses to leave the site.
Dan
A: 

There is a JavaScript onunload event that you might be able to utilize.

tomlog
and onbeforeunload
Jonathan Fingland
Onbeforeunload is very close but you will have "Are you sure you want to navigate away from this page?" as the opening line and the last line has to read "Press OK to continue, or Cancel to stay on the current page."You can insert a customised message in between but asking someone to click Cancel to take part in a survey is counter-intuitive. If they do click Cancel is there a way to detect Cancel was hit? (so that the page can do something to show a survey window).
Dan
+2  A: 

Unbelievable that even in 2009 people want to create crap sites.

AdBlock Plus in my FF stops all popups. If I use another browser I usually close the window before it get to load its content.

User