Reputation: 127
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.
Upvotes: 1
Views: 725
Reputation: 1453
Using this link I got you're desired effects in this codepen by doing this:
window.onerror = function(error, url, line) {
$('.alert').fadeIn();
};
Upvotes: 2