When catching js errors, we usually use try{}catch(e){}, and then obtain the error information through e.errorMessage and other methods and then report the error. But there may be little concern about the onerror event. Have we thought about how to report the line number where the error is located? If you have ever thought about this, have you ever been troubled by this problem? Do you think it is impossible to capture the wrong line number in js? In fact, I have encountered several of the above problems. Today, I read a piece of js code written by someone and suddenly discovered it. Onerror event, I have known about onerror a long time ago, but I have never understood its three parameters and its special properties. After my own research and testing, I have some new knowledge and understanding of the onerror event. When there is no error on the page, the window.onerror event does not exist, that is, null (nonsense! If there is no error, is it normal if onerror occurs?) We usually pass the operation function to be performed by passing the function name (by reference) Give the onerror event, such as window.onerror=reportError;window.onerror=function(){alert('error')}, but we may not know that the event also has three default parameters when it is triggered. They are error information, The URL of the error page and the error line number. You must know that this is an event, just like onclick and onmouseover events, but it has parameters. We can test it like this.