2014-05-07 104 views
1

我有一個表單,一旦它被提交,它'將用戶帶到「謝謝頁面」的想法是,如果用戶點擊後退按鈕,而不是回到表單,它將用戶帶到不同的頁面。我正在使用src="backfix.min.js",它正確地位於.js文件中。提醒消息,但由於某種原因,它沒有把用戶帶到我想要的頁面。當點擊後退按鈕「不工作」時重定向到不同的頁面

<!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> 
+0

您可以使用window.location.href相同happends嘗試window.location.href –

+0

'window.location.href的''而不是'document.location.href – Ejaz

+0

:警報消息,但當我點擊確定帶我回到形式 – Cessna

回答

1

瀏覽器後退按鈕運行window.history.back()

因此,使用window.history.back &覆蓋它:

bajb_backdetect.OnBack = function() 
{ 
    alert("Will take you back to the main page"); 
     window.history.back=function(){document.location='http://google.com';}; 

    } 

它爲我知道,我的意思是back.fixthis Library

UPDATE:

這是my example

如果還不行。包裝所有的代碼setTimeout功能:

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) 
+1

謝謝Abdennour Toumi它的作品完美!祝你今天愉快。 – Cessna

+0

@Cessna:查看更新 - –

+0

最後(200)的超時是多少?第一個和這個之間有什麼區別? – Cessna

相關問題