Sathishkumar Jayaraj
Sathishkumar Jayaraj

Reputation: 646

Modal popup on window close using javascript/jquery

I have a website where the customers come and purchase any product. But there are some customers who closes the tab without doing any purchase. I don't want to lose those customers. So i have decided to provide offers for those customers in the "modal" popup. This popup has to be displayed once the customer clicks the close button in the browser. This popup will have a form to select the offers, fill their contact details and submit the form. Once the form gets submitted, the window can be closed automatically. Is it possible to provide such a popup modal. I have surfed regarding this. Everyone says about the onbeforeunload with confirm and alert box. Could anyone help me on this.

Upvotes: 0

Views: 562

Answers (2)

farbod
farbod

Reputation: 91

you can't do it from your page code, only place I see this is in extensions.

Upvotes: 0

Rakesh G R
Rakesh G R

Reputation: 804

What you are trying to do cannot be done. That is after the user has clicked on close there is no way to do it.
But I think what you are looking for is what is called a 'Exit intent popup'.
The idea is simple: you use js/jquery to find if the user is 'about to' close the page(say from mouse movements and such) and display the said popup.
Here is one such plugin : BIOEP

You can just google 'Exit intent popups' for many more.

Upvotes: 1

Related Questions