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.
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
Post a Comment