使用javascript检查特定控制台错误是否发生/存在 [英] Checking if specific console error occurred/exists with javascript
本文介绍了使用javascript检查特定控制台错误是否发生/存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用javascript检查某个控制台错误,如果发生,请亲自检查alert()
.
I would like to check if a certain console error has occurred using javascript, and alert()
myself if it has.
错误看起来像这样:
00:00:34:0359 TimeEvent.COMPLETE
(anonymous function) @ VM17617:1
该算法将如下所示:
function checkError(console) {
if(console.error === "TimeEvent.COMPLETE") {
alert("The error is present");
}
}
我对控制台不是很熟悉,并且对Google的研究还不够深入.有人可以指出我正确的方向吗?
I'm not very familiar with the console, and haven't gotten much further with Google research. Can somebody point me in the right direction?
推荐答案
I ultimately solved my question by following this blog post on taking over the console with javascript.
这是我的最终代码:
var original = window.console
window.console = {
error: function(){
//Gets text from error message.
errorText = arguments['0'];
if (errorText.includes('TimeEvent.COMPLETE')) {
//DO STUFF HERE
}
original.error.apply(original, arguments)
}
}
这篇关于使用javascript检查特定控制台错误是否发生/存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文