How to detect on-page 404 errors using JavaScript?

前端 未结 4 1838
借酒劲吻你
借酒劲吻你 2020-12-05 00:30

I have an HTML page where several JavaScript, CSS and images files are referenced. These references are dynamically injected and user can manually copy the HTML page and the

4条回答
  •  生来不讨喜
    2020-12-05 01:06

    you can use the onload and onerror attributes to detect the error

    for example upon loading the following html it gives alert error1 and error2 you can call your own function e.g onerror(logError(this);) and record them in an Array and once the page is fully loaded post is with single Ajax call.

    
        
            
        
        
            
        
    
    

提交回复
热议问题