Lightbox with cookies not working when back button is pressed

  • Profile Image
    Diego Gonzalez
    Asked on May 12, 2015 at 12:25 AM

    I am using this:

    <?php

    $showlightbox="0";

    if(!isset($_COOKIE['beenhere'])) { 

    // FIRST VISIT TO WEBPAGE THIS SESSION

        setcookie("beenhere", '1', time()+ 10800,"/","mydomain.com");

    $showlightbox="1";

    }

     

    ?>

     

    <?php

    if ($showlightbox) { ?>

     

    <script>

          function openColorBox(){

            $.colorbox({iframe:true, width:"880px", height:"710px", href: "http://mydomain,com/myiframe/"});

          }

          

          function countDown(){

            seconds--

            $("#seconds").text(seconds);

            if (seconds === 0){

              openColorBox();

              clearInterval(i);

            }

          }

     

          var seconds = 1,

              i = setInterval(countDown, 1000);

        </script>

     

    <?php  } ?>

     

    It works at the firs time, then if I went to another section of the webpage and press BACK BUTTON the script shows me again the iframe in the lightbox, If I refresh again the script stops. So the issue is just when I press the Back Button in Firefo, IE and Chrome.

    Regards

  • Profile Image
    ashwin_d
    Answered on May 12, 2015 at 07:29 AM

    Hello Diego,

    We would like to check your lightbox form.

    Please share the web page URL where you have embedded your lightbox form and we will take a look.

    We will wait for your response.

    Thank you!

  • Profile Image
    Mariano 
    Answered on May 26, 2015 at 10:34 AM

    Hi there! 

    How can I do to show the pop up at least 3 times instead 1 time?

    Thanks!

  • Profile Image
    Carina
    Answered on May 26, 2015 at 11:08 AM

    @Mariano

    I moved your thread to a new one. You can find it here:

    http://www.jotform.com/answers/576082 

    Thank you