EarningWarrior - The War of Marketing.
Mobile back button redirect Code - Printable Version

+- EarningWarrior - The War of Marketing. (http://earningwarrior.com)
+-- Forum: Marketing Discussion (http://earningwarrior.com/F-Marketing-Discussion)
+--- Forum: Graphics, Programming and Webmaster (http://earningwarrior.com/F-Graphics-Programming-and-Webmaster)
+--- Thread: Mobile back button redirect Code (/P-Mobile-back-button-redirect-Code)



Mobile back button redirect Code - NeerX - 10-30-2017

Code:
(function(window, location) {
history.replaceState(null, document.title, location.pathname+"#!/history");
history.pushState(null, document.title, location.pathname);


window.addEventListener("popstate", function() {
 if(location.hash === "#!/history") {
   history.replaceState(null, document.title, location.pathname);
   setTimeout(function(){
     location.replace("http://www.redirect-url.com");
   },0);
 }
}, false);
}(window, location));