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

211
Views
evitar que el usuario haga clic en el botón Atrás del navegador

Quiero deshabilitar el botón Atrás del navegador. He probado algunos códigos javascript para implementar lo mismo. Pero esos códigos no cumplían con mis requisitos. Funciona en Firefox pero no funciona en Chrome y Edge. A veces funciona los tres pero aleatoriamente funciona y no funciona.

¿Alguien puede compartirme el script para deshabilitar el botón Atrás en todos los navegadores sin fallas como el comportamiento aleatorio?

Aquí mostré algunos scripts que he probado.

 history.pushState(null, null, window.location.href); history.back(); window.onpopstate = () => history.forward(); history.pushState(null, null, location.href); history.back(); history.forward(); window.onpopstate = function () { history.go(1); };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede consultar el siguiente código. Pruebo el ejemplo de código en Edge, Chrome y Firefox, funciona bien.

Guarde este archivo como .html para la primera página:

 <!DOCTYPE html> <html> <head> <title>First Page</title> <script type="text/javascript"> function preventBack() { window.history.forward(); } setTimeout("preventBack()", 0); window.onunload = function () { null }; </script> </head> <body> <h3>This is first page</h3> <a href="b.html">Goto second Page</a> </body> </html>

Guarde este archivo como b.html para la segunda página:

 <!DOCTYPE html> <html> <head> <title> Blocking Back Button using javascript </title> </head> <body> <h3>This is second page</h3> <p> On this page, back button functionality is disabled. </p> </body> </html>

Ejecute a.html y haga clic para navegar a b.html. Luego haga clic en el botón Atrás del navegador en b.html, no navegará a a.html.

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!