Getting data from the browser's console using javascript
Asked Answered
T

1

6

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.

Tailorbird answered 20/2, 2011 at 11:30 Comment(3)
possible duplicate #1535171Eyestalk
True , but I think my answer has a link to much more helpful info, with a robust full code samplePliers
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.Tailorbird
P
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.com/javascripts/notifier.js

Pliers answered 20/2, 2011 at 11:39 Comment(2)
their implementation of it seems to be rather interesting and i believe that i may do something similar with my system.Tailorbird
hoptoadapp.com/javascripts/notifier.js is now - airbrake.io , I tried using it but not a straight forward help. Need more time to set it up.Hildy

© 2022 - 2024 — McMap. All rights reserved.