Show pop-up on tab close with custom message
This code is useful when we want to apply a pop-up when a user is closing the tab. With the use of this code you can easily restrict the pop-up on page refresh or on navigating to other pages of the same website. Use this code in your header.php file :
<script type="text/javascript"> function PopIt() { return "write your custom message here"; } function UnPopIt() { /* nothing to return */ } jQuery(document).ready(function() { window.onbeforeunload = PopIt; jQuery("a").click(function(){ window.onbeforeunload = UnPopIt; }); }); </script>
We can write our custom message to be shown in pop-up. Just type your message in place of “write your custom message here” written in above mentioned code.
Note : Custom message will not show in mozilla firefox browser.
You are sharing very interesting content. Your articles can go viral easily.
Thanks Palma..I am just trying to collect or share most useful things in a simple way.
Just want to say your article is as astounding. The clearness in your
post is just excellent and i could assume you
are an expert on this subject. Fine with your permission let me to grab your feed to keep
updated with forthcoming post. Thanks a million and please continue the
rewarding work.
Thanks for the appreciation, this will surely boost my confidence. For the feeds I am preparing a newsletter to update all my users about the forthcoming post.
Nice article i will use it on my website.