View Full Version : Prompt the visitor to optionally give feedback when leaving the site

03-17-2009, 04:20 PM
Hi All,

I am newbie in webdesign field. I would like to add a prompt when a visitor of my website leaves the site or closes the browser.

The prompt should be to optionally give his/her feedback about the site.
--> User can fill a simple form with comment & email id --> In this case, the comments should go to our mail id
--> The user can also leave the site without giving the feedback, saying NO to the prompt.

How can I create this?

Thanks in advance...

03-17-2009, 04:48 PM
Make use of the onunload event (http://reference.sitepoint.com/html/event-attributes/onunload) and display some lightbox window (http://particletree.com/features/lightbox-gone-wild) to show your feed back form

Philip M
03-17-2009, 05:06 PM
Make use of the onunload event (http://reference.sitepoint.com/html/event-attributes/onunload)

Every browser listed supports this onunload attribute. However, it should be avoided as it encourages the mixing of content and behavior.

The trouble with using mailto: to send form results is its unpredictabiity. The method it is highly dependent on the browser in use and the email client in use. In particular, some of the most popular versions of Internet Explorer/Outlook Express will not work correctly. With all of the browser troubles, you're likely to lose about half of your users' messages. Also, what about people with Javascript disabled?

In fact few browsers these days accept mailto as a form action. You need a really old browser for it to work as more modern browsers simply open the email program (if any) and ignore the form. If you are going to use a form then use a server-side formmail script as the action - there are several good free ones out there.

03-18-2009, 07:46 AM
Thank u both...