js 获取控制台的错误信息

时间:2016-08-27 23:17:04   收藏:0   阅读:1989
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<script type="text/javascript">
onerror = function(msg,url,l)
{
    var txt="";
    txt+= msg + "\n";
    txt+= "URL: " + url + "\n";
    txt+= "Line: " + l + "\n\n";
    alert(txt);
}

</script>
</head>

<body>
<input type="button" value="View message" onclick="test()" />
</body>
</html>

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!