最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

error handling - Getting data from the browser's console using javascript - Stack Overflow

programmeradmin1浏览0评论

I don't know if this has been asked before, but what i'd like to be able to do is get data from the error console within the browser itself(if it supports it) this would be for when a user sends off a bug report it'd pull up any errors related to pages at my website for things such as typos in code and other things that somehow managed to slip by. Also, in that regard is there a way to pass the errors from the console to a useable format? If this isn't possible, then i could just tell them to copy and paste what came up from the site itself.

I thought of this right now as i was thinking about how to make the bug reporting system run better since the entire thing is basically ran within the browser and for the backend I can easily just look at error logs but for the frontend ie javascript bits of things it's not goign to be as easy.

So to finish wrap all of this up in one little statement, is there an easy way to get the data from the error console and be able to send it along via javascript ie to a form, or something similar.

I don't know if this has been asked before, but what i'd like to be able to do is get data from the error console within the browser itself(if it supports it) this would be for when a user sends off a bug report it'd pull up any errors related to pages at my website for things such as typos in code and other things that somehow managed to slip by. Also, in that regard is there a way to pass the errors from the console to a useable format? If this isn't possible, then i could just tell them to copy and paste what came up from the site itself.

I thought of this right now as i was thinking about how to make the bug reporting system run better since the entire thing is basically ran within the browser and for the backend I can easily just look at error logs but for the frontend ie javascript bits of things it's not goign to be as easy.

So to finish wrap all of this up in one little statement, is there an easy way to get the data from the error console and be able to send it along via javascript ie to a form, or something similar.

Share Improve this question asked Feb 20, 2011 at 11:30 133794m3r133794m3r 5,1183 gold badges25 silver badges37 bronze badges 3
  • 1 possible duplicate stackoverflow./questions/1534671/… – Adeel Commented Feb 20, 2011 at 11:36
  • 1 True , but I think my answer has a link to much more helpful info, with a robust full code sample – macarthy Commented Feb 20, 2011 at 11:41
  • hmm it seems to be a duplicate but for some reason when i searched for it, i got no options that seemed remotely like it. – 133794m3r Commented Feb 20, 2011 at 13:42
Add a ment  | 

1 Answer 1

Reset to default 3

You can use the onerror event in JS to get the details of the error. Hoptoad do this for example and log the errors to their console, Their code re-uses lots of nice JS scripts including a printStackTrace function that is great.....

You can see how they do it here:

http://hoptoadapp./javascripts/notifier.js

发布评论

评论列表(0)

  1. 暂无评论