-2

I am trying to resolve this.

In my page I have the Bpopup plugin. so here is my code:

SCRIPT:

<script type="text/javascript">

$(document).ready(function() {
    $('#element_to_pop_up').bPopup({
        speed: 650,
        transition: 'slideDown'
    });
});
</script>

ELEMENT THAT SHOWS THE POPUP

<div id="element_to_pop_up">
 <a class="b-close"><a/>

<p> hi </p>

</div>

What I want to do is to make that popup appear only once a day. I know it has something to do with cookies. Please help me.

Valentin Mercier
  • 5,256
  • 3
  • 26
  • 50
Rodrigo
  • 63
  • 2
  • 9

2 Answers2

0

Use Javascript cookies for this:

Click the W3Schools reference will help you

http://www.w3schools.com/js/js_cookies.asp

ivanfromer
  • 329
  • 1
  • 5
0

jQuery approach

$.cookie("popup_showed", 1, { expires : 1 });

and then get the value of the cookie to check if was already shown:

$.cookie("popup_showed");

See more at Kazar's post and jQuery.cookie plugin

PS. Try not using the capslock - it makes your post less readable.

Community
  • 1
  • 1
Michal Leszczyk
  • 1,849
  • 15
  • 19
  • Thank you for the recomendation michal.. i have a question.. what is suppoused to be in "popup_showed" tag? i think there needs to be the Bpopup function? and how? :( – Rodrigo Jul 21 '14 at 18:51
  • `popup_showed` is the name of the cookie that you're setting. The algorithm should look somewhat like this: in your popup-showing function you check if the cookie exists, and if it does - you check when was it created. If it was created `today`, then you're doing nothing (not showing the popup). If the cookie doesn't exist - you show the popup and set the cookie. And so it goes... :) – Michal Leszczyk Jul 21 '14 at 19:21