Home >Web Front-end >JS Tutorial >The onerror event was not found when parsing the img image. Stack overflow at line: 0_javascript skills
When opening the web page, it prompts Stack overflow at line: 0. I made a screenshot as follows:
After analysis, it was found that there is code similar to the following in the webpage:
Analysis: Pay special attention to onerror. When the picture does not exist, onerror will be triggered, and onerror specifies a NoPic.gif picture for img. That is to say, pic.gif will be displayed if the picture exists, and noPic.gif will be displayed if the picture does not exist. But here comes the problem. If noPic.gif does not exist, onerror will continue to be triggered, causing a loop, so an error occurs.
Note: If the image exists but the network is not smooth, onerror may also be triggered.
Solution: First method: Remove the onerror code; or change the onerror code to something else; or ensure that the image in onerror is small enough and exists.
Second type:
Third method:
Use two