eozzy
eozzy

Reputation: 68770

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!

Upvotes: 0

Views: 1243

Answers (2)

Luca Matteis
Luca Matteis

Reputation: 29267

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);
}

Upvotes: 4

Sarfraz
Sarfraz

Reputation: 382909

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

You can still use cookies with javascript.

Upvotes: 1

Related Questions