Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
Function is not only calling once

I am trying to execute only once, but it is executing multiple times.

I am showing alert when user reaches the 90% of the page while scrolling. But it is showing the alert multiple times.

I have also tried:

  • By turning statement to true after executed.

But it didn't work

File page.html

var percent = 90;
var window_scrolled;

$(window).scroll(function() {
    window_scrolled = ($(document).height()/100)*90;

    if($(window).scrollTop() + $(window).height() >= window_scrolled) {
        var excuted = false
        if (!excuted) {
            alert("scrolled to bottom");
            excuted = true
        }
    }
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are always setting the excuted to false each time, so it always runs.

Try this:

var excuted = false
$(window).scroll(function() {
    window_scrolled = ($(document).height()/100)*90;
    if($(window).scrollTop() + $(window).height() >= window_scrolled) {
        if (!excuted) {
            alert("scrolled to bottom");
            excuted = true
        }
    }
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda