-
WideScenesAnswered on April 03, 2015 10:39 PM
Hi , I tried the code as per instructions, however still appears each time page is refreshed within same browser session. can you my page to see if correct? http://www.widescenes.com/Fiji2015.html
thanks
-
raulAnswered on April 03, 2015 10:52 PM
You're using an HTML page instead of a PHP page and this is why the code is not executed.
Try to change the extension of your file to .php so it's named as Fiji2015.php. if your hosting provider supports PHP and you've enabled it in your site. Then the lightbox script should be executed only one time.
-
WideScenesAnswered on April 03, 2015 11:06 PM
Thanks for your help, will give it a try. Is there any code that I can use for HTML page that does the same thing?
-
BenAnswered on April 04, 2015 05:12 AM
Unfortunately server side cookies are only available on the PHP side, but you could do the same with the javascript cookies.
When we change the code from above it would go from this:
<?php
$showlightbox="0";
if(!isset($_COOKIE['beenhere'])) {
// FIRST VISIT TO WEBPAGE THIS SESSION
setcookie("beenhere", '1');
$showlightbox="1";
}
?>to this:
<script type="text/javascript">
var cookieBeenHere = getCookie('jotformBeenHere');
document.cookie="jotformShowLightBox=0";
if(cookieBeenHere && (cookieBeenHere ==1 || cookieBeenHere == "1") ) {
document.cookie="jotformBeenHere=1";
document.cookie="jotformShowLightBox=1";
}
/* function taken from the page above */
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
</script>Do let us know how it works for you.
-
WideScenesAnswered on April 04, 2015 05:41 AM
Thanks Ben,
Assume I would still keep the original jotform lightbox code as well. If so have replaced the php code with above and still get the lightbox appearing each time I refresh the page within the same browser session. Maybe I am making a mistake with the code.
-
abajan Jotform SupportAnswered on April 04, 2015 10:43 AM
@WideScenes
When I view the source of your web page I'm seeing the PHP script, not the JavaScript one. Here's a screenshot of your page's source:
It can't be a caching issue with my browser because this is the first time I'm visiting that page. Please ensure that you're saving the change correctly.
Do let us know how it turns out.
Thanks
-
WideScenesAnswered on April 04, 2015 09:20 PM
Hi Abajan,
Was testing locally, have now uploaded to site, so you can view page with html code. Let us know if there is a problem in how I have added the code.
Thanks so much for your help.
-
Welvin JotForm SupportAnswered on April 05, 2015 08:33 AM
Unfortunately, it's not working. Will check this and get back to you later today.
Thank you!
-
abajan Jotform SupportAnswered on April 05, 2015 10:55 PM
While our colleague Welvin works on a cookie solution, here's one which uses an HTML5 feature called Session Storage. Even though the doctype of your page is XHTML 1.0 Transitional and not HTML5, my tests indicate that it will still work.
Thanks
-
Diego GonzalezAnswered on May 11, 2015 07:33 PM
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 -
Kiran JotForm SupportAnswered on May 12, 2015 12:26 AM
Hello Diego,
Your query is moved to a separate thread and shall be addressed there shortly.
http://www.jotform.com/answers/568125
Thanks!