I've been trying to add the cookies into my script , but it hasn't been working at all . I am using this for Tumblr - I thought it was working since I would click 'update' on my blog while in 'editing mode' and the popup would show , but when I exit out it would disappear . I thought it was normal since my browser probably knew I already saw the pop-up and wouldn't show it to me again . I told my friend to check out the blog for me and let me know if she sees any pop-up , but she told me she didn't see anything . I just want my popup to open once per week for each visitor on my blog . Can anyone show me the correct code or tell me what I'm doing wrong ?
<script>
$(document).ready(function() {
var id = '#dialog';
if($.cookie('.window') != 'seen'){
$.cookie('.window', 'seen', { expires: 7, path: '/' }); // Set it to last a year, for example.
$j(".window").delay(2000).fadeIn();
$j('close').click(function(e) // You are clicking the close button
{
$j('.window').fadeOut(); // Now the pop up is hiden.
});
$j('.window').click(function(e)
{
$j('.window').fadeOut();
});
};
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').show(1000);
$('#mask').fadeTo("slow",0.5);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).show(2000);
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').hide();
$('.window').hide();
});
//if mask is clicked
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
</script>
This is the other part of the code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js">
</script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
Maybe try using local storage. It's like a cookie, but for javascript. It's also less complicated. W3 has a tutorial about it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.