<!DOCTYPE html>
<html>
<head>
<script>
var txt="";
function message()
{
try
{
adddlert("Welcome guest!");
}
catch(err)
{
console.log(err);
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
txt+="Click OK to continue.\n\n";
console.log(txt);
}
}
</script>
</head>
<body>
<input type="button" value="View message" onclick="message()" />
</body>
</html>
我想看看裏面error
內容(例如,err.message
),所以我把這個行:console.log(err);
在生色>控制檯,它shows:ReferenceError {}
所以我的問題是: 我怎麼能檢查內容/物業error
?