Tell me how to modify the script so that it displays a pop-up window at intervals of 24 hours (regardless of the pages visited, only once a day to one person when visiting any page of the site) I would be overly grateful.

<script type="text/javascript"> $(document).ready(function() { if($(window).width() > 992) { var show_after = parseInt('50', 20); var autoclose_after = parseInt('', 20); setTimeout(function () { $.magnificPopup.open({ items: { src: '#popup-11', type: 'inline' }, tLoading: '', mainClass: 'popup-module mfp-with-zoom popup-type-1', removalDelay: 200, }); if (autoclose_after > 0) { setTimeout(function () { $.magnificPopup.close(); }, autoclose_after); } }, show_after); } }); </script> 

    1 answer 1

    something like this.

     $(document).ready(function() { if($(window).width() > 992) { let date = localStorage.getItem('popup-last-date'); if(date!==null) { let NOW = new Date(); let DATE = new Date(date); if(Math.round((NOW - DATE) / 1000 / 60 / 60/ 24) >= 1) { ShowPopUp(); } } else { ShowPopUp(); } } function ShowPopUp() { $.magnificPopup.open({ items: { src: '#popup-11', type: 'inline' }, tLoading: '', mainClass: 'popup-module mfp-with-zoom popup-type-1', removalDelay: 200, }); let NOW = new Date(); localStorage.setItem('popup-last-date', NOW.getFullYear()+'-'+(NOW.getMonth()+1)+'-'+NOW.getDate()) } }); 
    • thanks, but does not work (((Anyway, the window appears on subsequent updates .. ( - ogd
    • @ogd updated. tested - it works. - Tsyklop
    • In safari, in private mode will not work. Because localStorage disabled in private mode. - Stepan Kasyanenko
    • it works just in safari for me, but in chrome there is no ... I have already cleaned the cookie for everyone, but it does not work ... - ogd
    • @ogd what version? - Tsyklop