Note that there are some explanatory texts on larger screens.

plurals
  1. POJS cookie for displaying content after x-th pageview
    primarykey
    data
    text
    <p>I am trying to find how may I set a javascript cookie so it displays a fancybox popup after say 4-th pageview of visitor.</p> <p>Here is the code that I am using to display a Fancybox popup, but as you may see, this displays the code only on first pageview and it expires after a day</p> <pre><code>function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value + ";domain=.mysite.net;path=/"; } function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i&lt;ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } jQuery(document).ready(function() { var show = getCookie("fancyreg"); if(show==null || show=="") { $.fancybox( { 'type' : 'iframe', 'href' : 'http://www.mysite.net/popup/', //URL to popup page or image 'autoDimensions' : false, 'width' : 480, 'height' : 260, 'transitionIn' : 'none', 'transitionOut' : 'none' } ); setCookie('fancyreg','1',1); } }); </code></pre> <p>I would also like if you may help me how to add a delay in my existing code so teh popup display after 3 seconds (3000 ms).</p> <p>I tried with setTimeout(function() as below</p> <pre><code> &lt;script type="text/javascript"&gt; jQuery(document).ready(function() { setTimeout(function() { $.fancybox({ 'type' : 'iframe', 'href' : 'http://www.mysite.net/popup/', //URL to popup page or image 'autoDimensions' : false, 'width' : 480, 'height' : 260, 'transitionIn' : 'none', 'transitionOut' : 'none' }) }, 4000); }); &lt;/script&gt; </code></pre> <p>but it does not work.</p> <p>As for controlling the pageviews, I have no idea how to set nor I could find any resource to help me through this.</p> <p>Thanks a lot </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload