Popup to open on leaving site

How do you code a popup to open only when someone is just about to leave your website please?

This would be an onunload event.

Thank you, I will check that out.

Whilst this isn’t answering the question… be aware that it can be very annoying for the user. It seems to be the in thing at the moment to fire a popup if you move the mouse towards the close or back buttons, which i find very annoying. Sometimes i am just moving the mouse and i get a ‘Before you go!!!’ message.

But having said that perhaps it does work for conversion rates overall so if you do impliment something like this monitor your stats closely for a while and check that it is doing more than annoying people.

The other one i find intensely irritating is when you have to fight with the back button to get out of a site. WHY WON’T YOU LET ME LEAVE! Sometime i have to click and hold to get the list of previous and choose from the list to get past the block (or whatever it is that is causing it).

I’ll point out that an onunload event cannot change the browser’s location - this is a security measure to prevent those sorts of things.

Browsers that use popup blockers will also block windows that open onunload, but they wont stop alerts. You also cant use it to capture where the user is going, for obvious privacy concerns.

Most of the ‘why wont you let me leave’ things is because they’ve put something into your ‘back history’ that is a javascript to bounce you forwards to the site again. Navigate forwards to google.com or something instead.

1 Like

but i don’t wanna go forward :frowning:

I think it was actually someone big like microsoft that did this to me the last time. The trouble is if i get there via a google search etc i would then have to retype my search if i went forward.

Sorry i went off on a tangent from the OP’s question.

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