2016-12-04 59 views
0

如果我想在點擊「確定」後將某人發送到另一頁(使用antoher鏈接),該怎麼辦?謝謝。在確認框中重定向到另一頁

<!DOCTYPE html> 
<html> 
<head></head> 
<body> 
<script type = text/javascript> 

var result = confirm("Do you really want to leave this page?"); 
if (result == true) { 
//Here somehow I should put the link 
} 

else {} 

<script> 
</body> 
</html> 
+0

嘗試'window.location.href' – Sid

+0

謝謝,這對我的作品。 – unknown2549

回答

1

你只需要使用location.href設置新的網址重定向。

var result = confirm("Do you really want to leave this page?"); 
if (result == true) { 
window.location.href="http://yourwebsite.com/yourpage"; 
} 

else { 
// code the else part. 
} 

<script> 
+0

非常感謝。 – unknown2549