仅一次加载欢迎动画jquery/php [英] Loading welcome animation only once jquery/php
问题描述
在我的网站上,我有一个欢迎动画(使用jquery创建),该动画在任何人打开我的网站( www.mysite.com )时运行.然后,该用户转到我网站的另一个页面,例如 www.mysite.com/about ,然后单击返回首页( www.mysite.com ),动画再次显示向上.我该如何限制呢?
In my site i have a welcome animation (created with jquery) which runs when any one opens my website (www.mysite.com). Then the same user going to anther page in my site for example www.mysite.com/about then click back to home (www.mysite.com) the animation again shows up. How can i restrict this ?
共享一些逻辑,例如设置会话或设置超时等.
Share some logic like putting a session or settimeout or something like that.
推荐答案
这是使用 jQuery cookie插件:
http://jsfiddle.net/lollero/2nYBV/(或 您可能想要更改cookie过期的方式.该信息可以在插件页面中找到.按照我的方式,它在每次浏览器会话后都会失效.
jQuery:
如果设置了cookie,您也可以轻松地将其隐藏. 1.设置cookie 2.如果设置了cookie,则if语句触发隐藏.
// If "welcome" cookie is not set...
if ( $.cookie('welcome') === null ) {
// Show welcome text.
$('#welcome').show();
// Set the "welcome" cookie, so that the
// welcome text will not be shown after this.
$.cookie('welcome', true );
}
CSS:
#welcome {
display: none;
}
HTML:
<div id="welcome">Welcome</div>
这篇关于仅一次加载欢迎动画jquery/php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!