views:

69

answers:

2

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!

+1  A: 

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

You can still use cookies with javascript.

Sarfraz
+3  A: 

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);
}
Luca Matteis
Those functions are great and very useful, but I need to save lines here because I just need it once. Thanks!
Nimbuz