Capture contents of Firefox/IE error console through code?

时间秒杀一切 提交于 2019-12-10 15:48:31

问题


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.


回答1:


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?... ;-)



来源:https://stackoverflow.com/questions/1534671/capture-contents-of-firefox-ie-error-console-through-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!