<html>
<head>
<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 = "https://www.w3school.org.cn/";
}
}
}
</script>
</head>
<body>
<input type="button" value="查看消息" onclick="message()" />
</body>
</html>