Reputation: 1173
Any way to tell the script on page x.html not to run if user has visited page y.html? Would like to stay away from the cookies...
Can this be done with session or local storage? On stackoverflow I found only scripts with cookies...
EDIT: Can someone help with something like this:
if (there is data stored in localStorage for this page) {
// do stuff
}
Upvotes: 1
Views: 1890
Reputation: 6414
Just read the localStorage
and check if you already saved a visit. If not, run your script (like the alert
in my example) and save the visit in localStorage
.
var ls = localStorage.getItem('namespace.visited');
if (ls == null) {
alert("Your first visit");
localStorage.setItem('namespace.visited', 1)
}
Upvotes: 6