使用 javascript 从浏览器控制台获取数据
我不知道以前是否有人问过这个问题,但我想要做的是从浏览器本身内的错误控制台获取数据(如果它支持),这将用于当用户发送一个错误报告它会提取与我网站页面相关的任何错误,例如代码中的拼写错误和其他不知何故漏掉的内容。另外,在这方面,有没有办法将错误从控制台传递为可用的格式?如果这是不可能的,那么我可以告诉他们复制并粘贴网站本身的内容。
我现在就想到了这一点,因为我正在考虑如何使错误报告系统运行得更好,因为整个事情基本上都是在浏览器中运行的,对于后端,我可以轻松地查看错误日志,但对于前端,即 javascript 位事情不会那么容易。
因此,为了将所有这些内容包装在一个小语句中,是否有一种简单的方法可以从错误控制台获取数据并能够通过 javascript 将其发送到表单或类似的东西。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用JS中的onerror事件来获取错误的详细信息。例如,Hoptoad 就是这样做的,并将错误记录到他们的控制台,他们的代码重复使用了许多漂亮的 JS 脚本,包括很棒的 printStackTrace 函数......
您可以在这里看到他们是如何做到的:
http://hoptoadapp.com/javascripts/notifier.js
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