I have a form that once it's submitted it' takes the user to a "Thanks page" the idea is that if the user clicks in the back button, instead of going back to the form it takes the user to a different page. I'm using src="backfix.min.js"
which is properly in a .js file. Is alerting the message but for some reason it's not taking the user to the page i want to.
<!DOCTYPE html>
<html>
<head>
<title>Thank You!</title>
<script type="text/javascript" src="backfix.min.js"></script>
<script type="text/javascript">// <![CDATA[
bajb_backdetect.OnBack = function()
{
alert("Will take you back to the main page");
document.location.href = 'http://goggle.com';
};
</script>
</head>
<body style="background-color: white" >
<div align="center" >
<img alt="thanyou" src="Images/thank_you[2].png" width="800" height="600">
</div>
</body>
</html>
Browser Back button run window.history.back()
.
Thus, Use window.history.back
& Override it :
bajb_backdetect.OnBack = function()
{
alert("Will take you back to the main page");
window.history.back=function(){document.location='http://google.com';};
}
It works for me known that i mean by back.fix
this Library
UPDATE :
This is my example :
If does not work yet . Wrap All code in setTimeout
function :
setTimeout(function(){
bajb_backdetect.OnBack = function()
{
alert("Will take you back to the main page");
window.history.back=function(){document.location='http://google.com'}
}
},200)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.