Automatic feedback on JavaScript error

前端 未结 6 1027
再見小時候
再見小時候 2020-12-23 22:56

Is there a way to get an automatic feedback if an error (even syntax errors) occurs when running a JavaScript on the client side?

I was thinking of something like th

6条回答
  •  温柔的废话
    2020-12-23 23:21

    One technique is to use Ajax for Javascript error logging

    Every javascript error can be trapped in the window.onerror event. We can return true or false so we can choose if the user shall see the normal javascript error dialog. This script will, in the very unlikely event of a javascript error, gather information about the error and send a httprequest to a page which will log the javascript error to the database.

提交回复
热议问题