Login Member
close
Subscribe
Home Addson
Anti Back Button with Redirect Link

Anti Back Button with Redirect Link

"Javascript code anti back button with customizable redirect link. To trap users on current page and redirect if they attempt to leave."

anti back button with popup link

Details

This code is designed to manipulate the browser's history and navigation behavior to trap users on the current page and redirect them to a specific URL if they attempt to leave. While it can serve specific purposes, it should be used cautiously to avoid negatively impacting user experience.

Potential Use Cases

  • Anti-abandonment : Websites might use this technique to prevent users from leaving a page prematurely, such as during a checkout process or while viewing important content.
  • Redirect control : The code ensures that users are redirected to a specific page (https://www.yztheme.my.id/p/recent-comments.html) if they attempt to navigate away.


Demo

Try to navigating back or forward on this page.


Code

JavaScript

history.pushState(null, document.title, window.location.href);
window.addEventListener("popstate", function (event) {
  window.open("https://www.yztheme.my.id/p/recent-comments.html", "_blank");
});
window.addEventListener("scroll", function () {
  history.pushState(null, document.title, window.location.href);
});


Help Me Install
Comments
Form Checkout
Add Voucher %
By purchasing, you agree to all terms.
Konfirmasi Pembayaran