Pulling cookie value with jQuery for MailChimp popup
I'm trying to read a cookie, but don't have a clue how, basically.
The cookies are being set OK, but don't seem to be read properly.
Here's what I have at the moment:
mce_jQuery(document).ready(function(){
mce_jQuery('#mc_embed_signup').hide();
cks = document.cookie.split( ';' );
var show=true;
for(i=0;i<cks.length;i++){
parts = cks[i].split('=');
if( parts[0].indexOf('MCEvilPopupClosed')>0 ) show = false;
}
It then runs on to do the following, but I'd like to simplify开发者_如何学编程 the above and not worry about the expiry date - only do the if(show=true) bit below when:
IF MCEvilPopupClosed value = yes...
if (show=true){
mce_jQuery('#mc_embed_signup a.mc_embed_close').show();
setTimeout( function(){ mce_jQuery('#mc_embed_signup').fadeIn();} , 1000);
mce_jQuery('#mc_embed_signup a.mc_embed_close').click(function(){ mcEvilPopupClose();});
}
});
Not really sure how to go about doing this?
Use https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js
var mycookie = $.cookie('the_cookie')
精彩评论