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

366
Views
¿Hay alguna manera de mostrar algo cuando pasa el cursor por las pestañas de Chrome en Javascript?

Estoy tratando de mostrar un anuncio cuando el usuario se desplaza menos del 57% pero intenta cerrar/cambiar la pestaña del navegador. Este es todo mi JS hasta ahora. Y también, ¿hay alguna manera de tener 1 iteración del modal dado, y solo para mostrarlo en la actualización de la página? Probé con window.onbeforeunload pero parece que no funciona.

 // Modal window.addEventListener("scroll", (e) => { let rootElement = document.documentElement; let scrollTop = rootElement.scrollTop; let pageHeight = rootElement.scrollHeight; let getPercent = (scrollTop / (pageHeight - rootElement.clientHeight)) * 100; if (getPercent >= 57) { document.querySelector(".modal").style.display = "block"; } console.log(getPercent); window.onclick = function (e) { if (e.target == document.querySelector(".modal")) { document.querySelector(".modal").style.display = "none"; } }; }); document.getElementById("close").addEventListener("click", (e) => { e.preventDefault(); document.querySelector(".modal").style.display = "none"; }); function showAd() { return (document.querySelector(".modal").style.display = "block"); }

about 4 years ago · Santiago Gelvez
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!