ป้ายกำกับ: Error

Javascript DebuggingJavascript Debugging

Code สั้น ๆ ไว้แสดง message เวลา javascript มี error หรือจะดัดแปลงให้ส่ง error กลับไปที่ server ผ่าน ajax ก็ได้ครับ

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>javascript onerror</title>
</head> <body>
<script>
window.onerror = function (msg, url, line) { str = "Message :\t\t"+msg+"\nUrl :\t\t\t"+url+"\nLine number :\t"+line; alert (str) ;
} /* ตัวอย่างไปเรียก function ที่ไม่มีจริง */
noBody () ;
</script>
</body>
</html>

เรื่องที่เกี่ยวข้อง