A
A
Alexander2015-01-03 18:34:56
JavaScript
Alexander, 2015-01-03 18:34:56

How can I check and set cookies in my code?

Good afternoon!
I have a problem. I'm not strong in js, I ask for your help!
There is a code:

$(document).ready(function() {
  $(document).mousemove(function(pos) {
    if(pos.pageY <= 70) {
      $('#myModal').modal();
    }
  });
});

I need this code to work once a week (Showing a modal window)
I can't add jquery.cookies to this code. You need to set cookies after showing the modal window, if there are cookies, do nothing. Help me please

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vista1x, 2015-01-03
@Tuborg

$(document).ready(function() {
  if (!$.cookie("popup")) {
    alert('нет кук');
    $.cookie("popup", 1, { expires : 7 });
  }
});

A
Alexander, 2015-01-03
@Tuborg

Thank you! Decided this way

if ($.cookie("popup")==undefined) {
$.cookie("popup",1,{expires:10});
$(document).ready(function() {
  $(document).mousemove(function(pos) {
        if(pos.pageY <= 70)
        {
          $('#myModal').modal();
        }
  });
});
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question