通过代码捕获Firefox / IE错误控制台的内容? [英] Capture contents of Firefox/IE error console through code?

查看:128
本文介绍了通过代码捕获Firefox / IE错误控制台的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以捕获Firefox或IE javascript错误控制台的内容?我想添加一个功能,当用户点击我的网站上的报告错误链接时,它也会沿着控制台的内容发送,因为这里有任何有用的错误。这样,我不必告诉他们手动打开它,并复制&粘贴到我的内容。

解决方案

您可以挂钩到window.onerror事件并发送请求到您的服务器的细节。

请注意,它不适用于所有的浏览器,并且错误的细节会因浏览器而异。例如IE可能会返回这么有用的哦:对象不支持属性或方法,你想知道哪个对象,什么属性?...; - )


Is it possible to capture the contents of either the Firefox or IE javascript error console? I'm thinking adding a feature where when a user clicks the 'Report A Bug' link on my site, it also sends along the contents of the console, incase there are any useful errors in it. That way I don't have to tell them to manually open it and copy & paste the contents to me.

解决方案

you can hook into the window.onerror event and send a request to your server with the details.

Just be aware that it won't work on all browsers, and the details of the error will vary by browser. e.g. IE may return the oh so helpful: "Object does not support property or method" and you're left wondering which object, what property?... ;-)

这篇关于通过代码捕获Firefox / IE错误控制台的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆