Override window.alert
Publikováno: 11.2.2020
For years the only bit of feedback web developers could get was via alert("{str}") calls. These days we have the web console but, in rare cases, we don’t have a console and alert calls are our only window into a value at a given time. One problem: if an alert sneaks into production code, your […]
The post Override window.alert appeared first on David Walsh Blog.
For years the only bit of feedback web developers could get was via alert("{str}")
calls. These days we have the web console but, in rare cases, we don’t have a console and alert
calls are our only window into a value at a given time.
One problem: if an alert
sneaks into production code, your site looks like it’s been hacked. Your site looks like it’s malware! To prevent any of those issues, you can add this snippet to your production build:
window.alert = console.log
This tiny line of JavaScript could save your site from catastrophe. There are many cases for overriding native functionality and this is a great example!
The post Override window.alert appeared first on David Walsh Blog.