2016-12-04 54 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