<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script>
//location对象
function f1(){
var b = confirm("您确定要离开本页面吗?");
if(b){
location.href="http://www.baidu.com";
}
}
//刷新
function f2(){
location.reload();
}
</script>
</head>
<body>
<input type="button" value="百度" οnclick="f1();">
<input type="button" value="刷新" οnclick="f2();">
</body>
</html>