我需要在cookie过期时显示fancybox,但这不起作用?任何人都可以帮助我吗?
var timer = 1;
$.cookie('popuptimer', 'timer', { expires: 2 * 60 * 1000 });
if($.cookie("popuptimer") == true){
} else {
$.fancybox({
overlayOpacity: 0.8,
overlayColor: '#000',
type: 'iframe',
width: 625,
height: 550,
overflow: 'auto',
padding: 0,
href: '<?php echo base_url(); ?>feedback'
});
}
答案 0 :(得分:0)
即使用户转到另一个页面(此脚本必须位于每个页面上),此解决方案仍然有效。
function showPopuptimer(){
$.fancybox({
overlayOpacity: 0.8,
overlayColor: '#000',
type: 'iframe',
width: 625,
height: 550,
overflow: 'auto',
padding: 0,
href: '<?php echo base_url(); ?>feedback'
});
}
if(!$.cookie("popuptimer") && $.cookie("olduser")){
//Cookie has expired since the last visit
showPopuptimer();
}else if($.cookie("popuptimer") && $.cookie("olduser")){
//Wait for the cookie to expire, then show the box
setTimeout(showPopuptimer,$.cookie("popuptimer"));
}else{
$.cookie("olduser",true);
$.cookie('popuptimer', 'timer', { expires: 2 * 60 * 1000 });
setTimeout(showPopuptimer,2 * 60 * 1000);
}
答案 1 :(得分:0)
您可能正在寻找......:
http://paulirish.com/2009/jquery-idletimer-plugin/
检查演示和线程,希望你能得到另一个想法