Hi, We all know that everyone is a propective client right? I am here to show you how you can get that user who just clicked close on your web page. Let’s have this user stay before he decides to go on his way and never come back.
First, all you will need is a little bit of HTML knowledge. I’ll walk you through the code so you don’t need to worry.
We then setup our script by defining some variables on a new
This will define how our Script runs.
detectbluris a boolean(true/false) value that determines whether the script should be fired whenever the user leaves your page without closing it. (e.g, change tab window)
interruptis a boolean(true/false) value that determines whether the script should be fired whenever the window is going to be closed and interrupt the user with a custom message defined below.
interrupt_messagea string value that is displayed on the interrupt confirmation box is fired.
We then paste the following code before the ending
Whoah! That's a lot of code there! well you don't need to understand all of it actually but if you do, read the comments above.
Now everything that we need for the script to run is given, let's get to styling. Copy the following code inside the
What's awesome is that our markup can be styled using the .unblockable class without being used directly in the script.
Then finally, our markup
Provide your own design and customize to your heart's content.
I hope this tutorial helped you catch that client in his attempt to escape 🙂
This plugin requires the latest version of jQuery.
I have also made this script as a Plugin version for WordPress with added features and options. Check it out here.
If you see corrections or suggestions to the existing code, please comment below.