开发者

Alert once (jQuery)

Is it possible to alert a user just once about something on his first visit? Can't use cookies because its a static site, only html and 开发者_如何转开发javascript are used.

Thanks!


You can use cookies if it's only HTML and JavaScript... JavaScript can read/write cookies to the browser.

I would set a real basic cookie value, and check that before alerting what you need.

You can use this code (scroll down) to read/write cookies and then do something like this:

// if the cookie doesn't exit, 
// it means it's the first time the user is visiting this page
if(!readCookie('boom')) {

   // this will only run the first time
   alert("something");

   // now set the cookie value "boom" for 7 days
   createCookie('boom','1',7);
}


Can't use cookies because its a static site, only html and javascript are used.

You can still use cookies with javascript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜