Javascript: How to develop a exit popup?

In this short tutorial, I’m going to show you how to create an exit popup.

If you wish to simply ask the user if they wish to leave you can easily assign a function to the OnBeforeUnload directive. This method will prompt the user every time they attempt to navigate away from the page or close the window.

You can change the wordings within the function and place this function before </head>

<script type="text/javascript">
window.onbeforeunload = function() { return "Are you serious???\n\n\nMore than 10,000 global traders are making INSANE MONEY from this program right now!\n\nWatch the video and join them today!\nClick on CANCEL or STAY ON PAGE now to watch the video!"; }

Note: This method has been tested with IE8+, FireFox3+, Chrome and Safari 4+.

You may also like...