//点击按钮,弹出对话框,点击确定,跳转到链接的页面

//document.location.href="http://www.runoob.com/"; 

<!DOCTYPE html>

<html>

<head> 

<meta charset="utf-8"> 

<title>菜鸟教程(runoob.com)</title> 

<script>

var txt="";

function message(){

try{

adddlert("Welcome guest!");

}

catch(err){

txt="本页有一个错误。\n\n";

txt+="单击确定继续跳转\n";

txt+="或者单击取消返回\n\n";

if(confirm(txt)){

document.location.href="http://www.runoob.com/"; 

}

}

}

</script>

</head>


<body>

<input type="button" value="查看消息" />

</body>


</html>



//参考菜鸟教程的代码:http://www.runoob.com/try/try.php?filename=tryjs_try_catch2