I created nice popup for my Facebook page, but I have problem that it is annoying. I put it to appear on scroll, and close on button, but I want to change it to appear once weekly or monthly. I never did codded anything similar and I just found few pretty confusing answers around. This is what I have:
jQuery(document).ready(function( $ ) {
$('.clicky').on('click', function(){
$(this).closest(".box").remove();
});
$(document).scroll(function() {
var y = $(this).scrollTop();
if (y > 200) {
$('.box').fadeIn();
} else {
$('.box').fadeOut();
}
});
});
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<div class="box">
<div class="text">
1. Like page..
<br>
<input type="submit" value="Facebook stranica"
onclick="window.open('https://www.facebook.com/xxxxx')" >
<br>
2. Click i liked.
<br>
<input type="submit" value="i liked" class="clicky">
<br>
</div>
</div>
What is the most simple way to turn this to appear once weekly or monthly?
If you want to resolve based on when the user last saw the popup then you should use "localstorage" or a database and insert code that stores the last time the popup was viewed and checks if the specified amount of time has elapsed each time the user accesses the page You should.
On the other hand, if you want to show a popup at a specific time you want, you just need to get the time you specified and the current time and compare it.