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

166
Views
El detector de eventos popstate en el script Tampermonkey solo funciona después de hacer clic dentro de la página.

Tengo un script de Tampermonkey, debería evitar la acción de retroceso si el usuario hace clic en el botón de retroceso del navegador. Estoy usando el código de las respuestas a esta pregunta .

 // ==UserScript== // @name Prevent touchpad gestures/button of the page back action // @namespace https://github.com/remi-crystal // @version 0.1 // @description Use google.com for testing propose // @author Remi Crystal // @match https://*.google.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // always works console.log(document.title, location.href); // only works after any interaction window.addEventListener('popstate', function (event) { history.pushState(null, document.title, location.href); }); history.pushState(null, document.title, location.href); })();

Este detector de eventos funciona bien en general. Pero si no interactué como hacer clic o presionar una tecla dentro de la página (mover el cursor no cuenta), no funcionará (la página simplemente retrocede si hago clic en el botón Atrás o uso el gesto del panel táctil) . Otro código no importa.

¿Por qué podría pasar esto? ¿Cómo soluciono este problema?

Versión de mi navegador: Chrome 96.0.4664.110 (Official Build) (arm64)

about 4 years ago · Juan Pablo Isaza
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!