Posts

Showing posts from May, 2023
Redirect on Back Button Press
Auto Open Website on Back Button Auto Open Website on Back Button This page disables the back button functionality. If you try to go back, the desired website will open automatically.
// Listen for the back button click event window.addEventListener('popstate', function(event) { // Open the desired website window.open('https://example.com', '_blank'); }); // Push a new state to the history when the page loads window.history.pushState({ page: 1 }, '', ''); // Function to disable the back button functionality function disableBackButton() { window.history.pushState(null, '', ''); window.onpopstate = function() { window.history.pushState(null, '', ''); }; } // Call the function to disable the back button disableBackButton();
Your browser does not support the video tag.