Run jQuery only once when the site is loaded [duplicate]

0

I'm having a problem, I have the script below that every time the user uses the browser to go back to the main page this animation script executes.

I would like to know if there is anything I can do to run it only on the first user access, even without refresh.

$(document).ready(function() {
  /*ANIMAÇOES*/
  //$(".bolhasanimadas").addClass('animated slideInUp');
  $(".bolhasanimadas").addClass('animated slideInUp');
  $(".animacaoBolhas").delay(4000).slideToggle(50);
  $(".LogoAnimado").delay(800).fadeToggle(1);
  //$(".LogoAnimado").toggle( 6500 ).delay( 6500 );

  /*BARRA DE ROLAGEM*/
  setTimeout(function() {
    //$('body').css('overflow-y', 'scroll');
    $('body').addClass('barraOn');
  }, 4000);

});

Explaining better: Actually this jquery is an animation. And I would need a script to run this animation only when the user logs in to the site once. Once it has surfing and by chance give refresh or go back in the browser for Home and animation will not run again. This idea of leaving the animation in an index alone does not help.

    
asked by anonymous 09.03.2016 / 20:55

1 answer

0

The document.ready runs every time the page is created. The html does not recognize a postback, that is, when it returns through the browser everything that is in document.ready will run again.

From the descriptions, it appears to be an animation on the main page. I do not know if it is, but if it was you could use a main page that will run only once. A default.html / index.html page, which after showing the animations redirects to home.html for example.

By doing this you will be separating the incoming animation from your site from your home page. So every time the user returns to home.html page he will not see the animation again.

You'll only see the animation the first time you enter the site.

I do not know if it was very clear.

Hugs.

    
10.03.2016 / 01:44