javascript - How to detect if it is the first page of my site the user views? -


i'd perform animation on website if user's first time on website. found "first time visitor" code localstorage, didn't find this.

working fiddle demo

you can use either cookie or localstorage. consider have following html code:

<div id="first">     welcome visitor </div>  <p>this website.</p> 

we set display of first element none. never show.

#first {     display: none; } 

then check first time. if first time, show element (and maybe animation it):

// first time if (! localstorage.nofirstvisit) {     // show element     // , animation want     document.getelementbyid('first').style.display = 'block';      // check flag escaping if block next time     localstorage.nofirstvisit = "1"; } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -