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

194
Views
¿Cómo puedo capturar el clic fuera del navegador? Javascript

Para mi proyecto, necesito capturar todos los clics fuera del navegador en Javascript. Hay una manera de hacer eso ? Por ejemplo, preguntando al usuario el acceso correcto. Necesito una función como "onclick" que funcione incluso fuera del navegador.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Hay varios enfoques para detectar cuándo el enfoque se mueve fuera de la página actual, lo que sería un efecto secundario de hacer clic fuera de la ventana si la ventana tiene el foco actualmente.

No es posible detectar explícitamente los clics fuera de la página. Sería un problema de seguridad si una página web pudiera monitorear cómo el usuario interactúa con otras aplicaciones.

about 4 years ago · Santiago Trujillo Report

0

Para detectar clics fuera del elemento con JavaScript, podemos usar el método contains del elemento.

Por ejemplo, escribimos

 const specifiedElement = document.getElementById("a"); document.addEventListener("click", (event) => { const isClickInside = specifiedElement.contains(event.target); if (!isClickInside) { // ... } });

para seleccionar el elemento que queremos comprobar con getElemebntById.

Luego agregamos un detector de clics para toda la página con document.addEventListener.

En la devolución de llamada, llamamos a specificElement.contains con event.target para verificar si hicimos clic dentro del elemento a.

Si es falso, entonces hicimos clic fuera de él.

about 4 years ago · Santiago Trujillo Report

0

javascript detecta clic fuera del elemento

 var ignoreClickOnMeElement = document.getElementById('someElementID'); document.addEventListener('click', function(event) { var isClickInsideElement = ignoreClickOnMeElement.contains(event.target); if (!isClickInsideElement) { //Do something click is outside specified element } });

haga clic fuera de javascript

 // Vanilla js var ignoreMe = document.getElementById("ignoreMe"); window.addEventListener('mouseup', function(event){ if (event.target != ignoreMe && event.target.parentNode != ignoreMe){ // Place your output } });

https://www.codegrepper.com/code-examples/javascript/javascript+detect+click+fuera+de+elemento

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