Javascript Debugging

Byphunsanit

Javascript 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>

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

About the author

phunsanit administrator

    Leave a Reply