2010-10-18 71 views
0

我试图设置一个延迟的时间量的cookie。带.delay的jQuery .cookie?

我希望在页面上80分钟后设置cookie。

这里是我的代码 -

$(document).ready(function() { 
      // Set the cookie after 81 mins so the next visit has the button 
      $.cookie('EVGSalesLetter', 'visited').delay(4860000); 
     }); 
+0

我认为延迟()应该*之前*你想要的东西elay。 :) – bzlm 2010-10-18 18:59:05

+0

行之前的4个空格格式为代码。 'ctr-k'作为选择。 – 2010-10-18 19:03:13

回答

6

.delay()是动画队列,只是一般设置一个计时器使用setTimeout(),像这样:

setTimeout(function() { $.cookie('EVGSalesLetter', 'visited'); }, 4860000); 

我没有在这个棒document.ready,因为我假设(希望安全......),81分钟你的页面已经完全加载:)

+0

这当然是在网页上连续81分钟,而不是页面上的累积81分钟(可以使用cookie进行跟踪) – 2010-10-18 19:05:23

+0

谢谢你,这就像一个魅力! – 2010-10-18 19:13:33

+0

@MWoodard - welcome :) – 2010-10-18 19:13:53