这里的问题是我正在使用一个具有本机错误的javascript库,当按下某组按钮太多次(超过特定限制)时,该错误会不断弹出。 然后需要刷新页面(现在直到本机问题得到解决)。
我已将此警报添加到我的html中,基本上我希望它在控制台报告错误时弹出。 (我正在使用Chrome)
<div class="alert alert-danger" role="alert" style="display:none;">Please Refresh Page</div>要做到这一点,我基本上会像这样使用jquery:
$('.alert').fadeIn()但是我不确定如何触发那个简单的jquery调用。 我怎样才能在控制台上监听,当控制台报告错误时,调用该jquery函数使警报横幅可见?
我无法找到我的问题的明确答案,希望StackOverflow社区有它! 提前致谢。
The issue here is that I'm using a javascript library that has a native error that keeps popping up when a certain group of buttons are pressed too many times (over a specific limit). The page then needs to be refreshed (For now until the native issue is worked out).
I have added this alert to my html, essentially I want it to pop up the moment when the console reports an error. (I am using Chrome)
<div class="alert alert-danger" role="alert" style="display:none;">Please Refresh Page</div>To do this I would essentially use jquery like so:
$('.alert').fadeIn()However I am unsure as to how I would trigger that simple jquery call. How could I listen in on the console, and when the console reports an error, call that jquery function to make that alert banner visible?
I have not been able to find a clear answer to my question, hopefully the StackOverflow Community has it! Thanks in advance.
最满意答案
使用这个链接我通过这样做得到了你想要的效果在这个codepen中 :
window.onerror = function(error, url, line) { $('.alert').fadeIn(); };Using this link I got you're desired effects in this codepen by doing this:
window.onerror = function(error, url, line) { $('.alert').fadeIn(); };更多推荐
发布评论