How to display errors on web browsers without dev tools (like the Switch)
Web Development
1
Posts
1
Posters
99
Views
-
If you're working on a website for a console that doesn't have a modern browser, or web dev tools, and can't figure out why something is broken on the console, the following HTML snippet can be used to display and alert any javascript errors:
<script> window.onerror = function(message, source, lineno, colno, error) { alert(`Error: ${message}\nSource: ${source}\nLine: ${lineno}\nColumn: ${colno}\nError object: ${error}`); return false; }; </script>This will only help for websites where you can control the source code. It displays whatever errored on the page, and the filename and line number that generated it.