Script: Redirection to Required URL When Clicking “Back” in Browser


Here’s a script that redirects users to the URL you assigned when they click on the “back” button in the browser.  It is intended for extra monetization of traffic on the landing page.

Previously, we published these articles on complete traffic monetization with news showcases:

Below, you’ll find an actual script for implementing the latter method:

<script>
(function(window, location) {
var bbURL = 'YOURWEBSITE';
history.pushState(null, document.title, location);
window.addEventListener("popstate", function() {
history.replaceState(null, document.title, location);
setTimeout(function() {
location.replace(bbURL);
}, 0);
}, false);
}(window, location));
</script>

You must insert this script into the source code of your website, replacing “YOURWEBSITE” with the required URL to redirect users. We recommend writing it at the beginning, for example, in front of the <head> tag so that the code has time to load.


Like it? Share with your friends!

0 Comments

X