所以我使用colorbox来创建一个灯箱。目前我在第一页加载时已经这样做了,用户被显示为一个灯箱。 Cookie被丢弃,因此用户在15天内没有看到该灯箱。我想这样做,只有当用户滚动到div#cooler-nav时,才会加载lightbox。如何触发灯箱加载一旦用户滚动到某个Div
我的代码目前看起来是这样的:
<script type="text/javascript">
jQuery(document).ready(function(){
if (document.cookie.indexOf('visited=true') == -1) {
var fifteenDays = 1000*60*60*24*15;
var expires = new Date((new Date()).valueOf() + fifteenDays);
document.cookie = "visited=true;expires=" + expires.toUTCString();
$.colorbox({width:"700px", inline:true, href:"#subscribepop"});
}
});
</script>
附:我想保持灯箱每15天只加载一次的能力。
@Jasper已经解释了所有内容......(解除绑定除外,它确保您只显示一次colorbox) – ori
我可以运行您分享的代码并将灯箱加载一次div#cooler-nav。解绑也很好。不过,我无法弄清楚饼干的工作是正确的。 我想要做的是每15天只有一次灯箱展示。 链接到我的代码:http://pastebin.com/2VFKquAp –
该代码在Firefox 9.0.1中不起作用 –