2011-06-04 52 views
1

我有一个动画,我正在运行使用jQuery。我假设一个很好的方式只为访问者播放这个动画,就是设置一个cookie。我基本上需要它说你以前在这里,所以把列出的所有ID都设置为不透明:1是否有超简单的解决方案?感谢您的帮助设置Cookie只播放动画一次(jQuery)

$(document).ready(function(){ 
    $("#featureFade").animate({opacity:1},400,function(){ 
     $("#image").delay(300).animate({opacity:1},300,function(){ 
     $("#title").delay(300).animate({opacity:1},300,function(){ 
     $("#message, #move").delay(200).animate({opacity:1},300,function(){ 
      $("#move").animate({top: '400px',left: '0px'}, 500,function(){ 
      $("#nav,#contentContainer,#button,#footer,#topLevelNav").delay(1000).animate({opacity:1},700); 
       }); 
       }); 
       }); 
      }); 
    }); 
}); 

回答

1

我会做它在服务器端 - 如果cookie设置,只是不输出动画的代码...

2

使用jQuery Cookie Plugin你可以这样做简单地说:

// check for previous visit 
if ($.cookie('hasSeenAnimation') == null){ 
    // ... 
    // play animation 
    // ... 

    // set cookie to stop next visit 
    $.cookie('hasSeenAnimation','true'); 
}