0

I have used bootstrap popup modal but it appears every time on page loads. I have gone through every question & answer in Stackoverflow and tried every code but not worked. That's why I am posting this question again. I am not much familiar with Javascript and I am requesting to post the right code for me. My used codes are below:

<script>
jQuery(window).load(function(){
   setTimeout(function(){
       jQuery('#myModal2').modal('show');      
   }, 10000);
});
</script>
<div id="myModal2" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" style="font-size:18px; text-align:center;">Get The Latest & Best Coupon/Offer Alerts</h4>
            </div>
            <div class="modal-body">
    <h4 style="font-size:16px; text-align:center;">Subscribe to our mailing list to get the latest updates straight in your inbox.</h4>
    <hr>
                <center><?php echo do_shortcode('[newsletter_form type="minimal"]'); ?></center>
                <br>
                <h3 class="cb-subnl">We value your privacy & guarantee zero spamming. Subscribe now and receive 1 mail per day. Never miss out on latest coupons, deals and best offers!</h3>
            </div>
        </div>
    </div>
</div>
Amit Das
  • 41
  • 1
  • it will pop up every time as you have written code in window load event after 10 seconds. – Dhiren Sep 02 '18 at 04:48
  • If you only want to show the popup once per visit, you need to use browser cookies. Check if a defined cookie exists... if not, show the pop up and define the cookie... on the next page load, when the code checks for the cookie, it will find it and not execute the code to show the pop up. – VVV Sep 02 '18 at 04:51
  • Check this thread for cookie usage : https://stackoverflow.com/questions/1458724/how-do-i-set-unset-a-cookie-with-jquery – VVV Sep 02 '18 at 04:52

0 Answers0