Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the below code for fade In pop up. Once user visit one page the pop up come. When user visit another page the pop up not come because I have set the cookie. I want that when user come on the page and does not fill the form the pop up on same or another page should again come. When user fill the fade In form the pop up should not come again on same page or another page. I am using this code on wordpress site.


JavaScript
function ReadCookie(cookieName) {
    var theCookie = " " + document.cookie;
    var ind = theCookie.indexOf(" " + cookieName + "=");
    if (ind == -1) ind = theCookie.indexOf(";" + cookieName + "=");
    if (ind == -1 || cookieName == "") return "";
    var ind1 = theCookie.indexOf(";", ind + 1);
    if (ind1 == -1) ind1 = theCookie.length;
    return unescape(theCookie.substring(ind + cookieName.length + 2, ind1));
}

var cookievalue = ReadCookie("Visit");
if (cookievalue == null || cookievalue == "") {
   // Put Here Your FadeIn/FadeOut code
//Start

    var mce_jQuery = jQuery.noConflict();
    mce_jQuery(document).ready(function(){
    mce_jQuery('#sp').hide();
    cks = document.cookie.split( ';' );
    var show=true;
        for(i=0;i<cks.length;i++){>
          parts = cks[i].split('=');
          if(parts[0]=='MCEvilPopupClosed') show = false;
        }
        if (show){
          mce_jQuery('#sp a.close').show();
          setTimeout( function(){ mce_jQuery('#sp').fadeIn();} , 2000);
          mce_jQuery('#sp a.close').click(function(){ mcEvilPopupClose();});
        }
    });

    mce_jQuery(document).keydown(function(e){
       if (e == null) { 
           keycode = event.keyCode;
       } 
           else { 
           keycode = e.which;
       }
       if(keycode == 27){
               mcEvilPopupClose();
       }
    });

    function mcEvilPopupClose(){
    mce_jQuery('#sp').hide();
    var now = new Date();
        var expires_date = new Date( now.getTime() + 31536000000 );
        document.cookie = 'MCEvilPopupClosed=yes;expires=' + expires_date.toGMTString();
    }

    document.cookie = "Visit=1;path=/;domain=.google.com";
}
else if (cookievalue != null) {
   //Do nothing

}


Please help me. Thanks
Posted
Updated 18-Aug-13 23:40pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900