I have a jQuery
function, that produces an animation when my index.html
is loaded.
I would like this animation to happen only once. If you go on an other page, then come back on the index.html
, the animation should not happen.
But I would also like that when the index page is refresh, the animation is displayed.
I don't know if you get it... Anyway thanks !
Javascripts sessionStorage can make this possible.
This sessionStorage-variable will only be accessible while and by the window that created it is open. So, after closing the window, the sessionStorage variable will be undefined.
You can simply create this by using something like sessionStorage.firstVisit = 1
.
Simple wrap this in an if-statement to check whether to show the animation or not.
For more info on this check http://www.w3.org/TR/webstorage/#the-sessionstorage-attribute
Try this one !!
if (!sessionStorage.isActive) {
$('.your-div').animate(); //write your code to animate
sessionStorage.isActive= 1;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With