Site logo

[Resolved] Load animation only once per website visit

Home Forums Support [Resolved] Load animation only once per website visit

Home Forums Support Load animation only once per website visit

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1527874
    Dominik

    Hi there,

    we have made a small intro animation with javascript and css and need to show the animation only once per website visit. We couldn´t find out how this could be made.

    https://ccl.brandwerk-digital.com/

    Thanks for your help!
    Dominik

    #1528068
    David
    Staff
    Customer Support

    Hi there,

    aside of using Cookies to detect a users first visit you can use localStorage to store a variable for the visited status and then use that as a condition to run your code. Heres an example of that.

    https://stackoverflow.com/a/31867239

    #1533552
    Dominik

    Hi David,

    thanks for the input. I couldn´t get it run and tried the function with an alert. that works well – but only one time. Is it possible to create a function that runs the code once per website visit..if you click the start page a second, third,…time, no code will run. But if you close the window and open a new one…the code will run once again?

    Thanks!

    #1533587
    David
    Staff
    Customer Support

    Probably want to swap localStorage for sessionStorage see here:

    https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

    sessionStorage differs in that the variable is only stored for the current tab whilst it is open. Once closed sessionStorage gets cleaned.

    #1534802
    Dominik

    Perfect – Thank you very much!!!

    #1534810
    David
    Staff
    Customer Support

    You’re welcome

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.