The onerror event Stack overflow at line: 0 was not found when parsing the img image

  • 2020-03-30 01:03:16
  • OfStack

Stack overflow at line: 0. I took a screenshot as follows:

After analysis, the following code is found in the web page:

< Img SRC = "PIC. GIF" onerror = "javascript: this. SRC ="/noPic. GIF ';" Alt = "PIC" / >

Analysis: pay special attention to onerror, when the picture does not exist, it will trigger onerror, and onerror for img to specify a nopic.gif picture. In other words, if the picture exists, it will show PIC. GIF, and if the picture does not exist, it will show noPic. GIF. But the problem is that if nopic.gif also does not exist, then continue to trigger onerror, resulting in a loop, so there is an error.

Note: if the picture exists, but the network is not smooth, may also trigger onerror.

Solution: the first: :. Remove the onerror code; Or change the onerror code to other; Or make sure the picture in onerror is small enough to exist.

The second:
< The script type = "text/javascript" >  
< ! -  
      The function nofind () { 
              Var img = event. SrcElement;  
              . Img SRC = ".. /.. /.. / sys/common/images/fileoperation/icon/default. GIF ";  

Img. Onerror = null;             Control don't keep dancing  

      }  
// events are used to get one by one when it is not found;
/ / - >  
< / script>  

< Td align = "center" > < Img SRC = ".. /.. /.. / sys/common/images/fileoperation/icon / ${file. The suffix}. GIF "onerror =" nofind ();" / > ${file. The name} < / td>        

The third:
Use two < Img / >

< Style type = "text/CSS" >
Hidden {
Display: none;
}
< / style>
< Img SRC = "XXX. JPG" onerror = "enclosing class = 'hidden'; Xx. Class = "" / >
< Img SRC = "XXX. JPG" class = "hidden" / >


Related articles: