Can you have a CSS popup on exit with a survey in it?

Hi All

I am not too sure if this is the correct place to put this and it falls under several categories but ultimately we are developing in PHP.

We have built a website and we are getting visitors but not making sales… we are trying to work out why and want to out a quick, 4 bullet point survey up when someone leaves the website.

Is this possible and if so can someone please point me in the right direction.

Thanks for any help in advance.



There’s a onbeforeunload JavaScript event which is fired when a window is about to unload its resources. You can read about it here.

Theoretically, you could hook into this to ask visitors a question before they leave your site (kind of like those annoying “Are you sure you want to leave this page” boxes).

However, browser implementation is inconsistent and I’m not sure this is the right way to be going about things. It might be better to look at your analytics and seeing if you can identify some kind of pattern.


I don’t think that “on exit” is the best time to ask for a survey. Popups can be an annoyance at the best of times. Delaying someone who wants to leave won’t endear you to them.
If you are going to have a survey like this, choose a better time to display it and maybe a less intrusive method than a popup.

1 Like

You can’t display CSS popups on exit.

What you can do is something close to that. Have an invisible div at the top of the page, like 40px height or so, and when the user moves the mouse towards leaving the page and the cursor enters into this div zone, trigger the CSS popup. This also feels less annoying because, they are not being blocked or forced for a click. They can click exit and they will without any confirmation.

Popups or exit popups may not be user friendly if done inappropriately, but they are widely used for marketing purposes and there is a reason why they are still widely used: Annoying they may be for some, they do work.

Of course the mouse doesn’t have to be moved into that area in order to leave the page - there are plenty of keyboard and context menu alternatives.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.