Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
La función no solo llama una vez

Estoy tratando de execute only once , pero se está ejecutando varias veces.

Muestro una alert cuando el usuario alcanza el 90% de la página mientras se desplaza. Pero está mostrando la alerta varias veces.

También he probado:

  • Convirtiendo la declaración en true después de ejecutarla.

pero no funcionó

Archivo 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 answers
Answer question

0

Siempre está configurando el excuted en false cada vez, por lo que siempre se ejecuta.

Prueba esto:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!