HTML DOM onerror Event Last Updated : 23 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The HTML DOM onerror event is triggered when an interruption occurs while loading an external file. Some events that occur if there is some kind of disturbance to the media loading process are: onabortonemptiedonstalledonsuspend Supported Tags: <img> <input type="image">, <object> <link> <script> Syntax: In HTML: <element onerror="myScript"> In JavaScript: object.onerror = function(){myScript}; In JavaScript, using the addEventListener() method: object.addEventListener("error", myScript); Example: Using HTML HTML <!DOCTYPE html> <html> <body> <center> <h1 style="color:green"> GeeksforGeeks </h1> <h2>HTML DOM onerror event</h2> <img src="image.gif" onerror="gfgFun()"> <script> function gfgFun() { alert('Error!!'); } </script> </center> </body> </html> Output: Example: Using JavaScript HTML <!DOCTYPE html> <html> <body> <center> <h1 style="color:green">GeeksforGeeks</h1> <h2>HTML DOM onerror event</h2> <img id="logo" src="image.gif"> <p id="try"></p> <script> document.getElementById( "logo").onerror = function () { myFunction() }; function myFunction() { document.getElementById( "try").innerHTML = "Error!!"; } </script> </center> </body> </html> Output: Example: Using the addEventListener() method HTML <!DOCTYPE html> <html> <body> <center> <h1 style="color:green">GeeksforGeeks</h1> <h2>HTML DOM onerror event</h2> <img id="logo" src="image.gif"> <p id="try"></p> <script> document.getElementById( "logo") .addEventListener( "error", myFunction); function myFunction() { document.getElementById( "try").innerHTML = "Error!!"; } </script> </center> </body> </html> Output: Supported Browsers: The browsers supported by HTML DOM onerror Event are listed below: Google Chrome 10Edge 12Internet Explorer 9Firefox 1Apple Safari 6Opera 11.6 Comment More infoAdvertise with us Next Article HTML DOM onerror Event V Vijay Sirra Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM onopen Event The DOM onopen event occurs on an open connection with an event source. Related events: onmessage: Received the message.onerror: The problem occurs. Syntax: Using JavaScript:object.onopen = function(){myScript};Using the addEventListener() method:object.addEventListener("open", myScript); Example: U 1 min read HTML DOM onblur Event The HTML DOM onblur event occurs when an object loses focus. The onblur event is the opposite of the onfocus event. The onblur event is mostly used with form validation code (e.g. when the user leaves a form field). In HTML:<element onblur="myScript">html<!DOCTYPE html> <html lang="en 1 min read HTML DOM oncopy Event The HTML DOM oncopy event occurs when the content of an element is copied by the user. It is also applicable to the image, created with the element. It is mostly used with type=âtextâ. Note: There are three ways to copy the content of an element: Press CTRL + CSelect "Copy" from the Edit menu in you 2 min read HTML | DOM onshow Event The onshow event occurs when a user right click on en element and <menu> element is shown as a context menu. Supported Tags <menu> Syntax: In HTML: <element onshow="Script">In JavaScript: object.onshow = function(){Script};In JavaScript, using the addEventListener() method: object. 1 min read HTML DOM onkeydown Event The DOM onkeydown event in HTML occurs when a key is pressed by the user. Order of events related to the onkeydown event: onkeydownonkeypressonkeyup Supported HTML tags: All HTML elements, EXCEPT: <base><bdo><br><head><html><iframe><meta><param><scr 1 min read HTML DOM onmouseover event The DOM onmouseover event in HTML occurs when the mouse pointer is moved onto an element or its children. Supported Tags: It supports All HTML elements, EXCEPT: <base><bdo><br><head><html><iframe> <meta><param><script><style><title> S 1 min read HTML DOM onended Event The HTML DOM onended event occurs when the audio/video is ended. We can add some custom messages in this event like "Thank for watching", "Share", etc. Supported Tags: <audio> <video> Syntax: In HTML: <element onended="myScript"> In JavaScript: object.onended = function(){myScript} 2 min read HTML DOM onpaste Event The HTML DOM onpaste event occurs when some content is pasted in an element. this event works on every element like in <p> element if contenteditable set is true then we can paste content in <p> element. The HTML DOM onpaste event is mostly used in input element type="text". Supported Ta 1 min read HTML DOM onkeyup Event The HTML DOM onkeyup event in HTML occurs when a key is released after pressing by the user. Order of events related to the onkeyup event. onkeydownonkeypressonkeyup Syntax: In HTML:<element onkeyup="myScript">In JavaScript:object.onkeyup = function(){myScript};In JavaScript, using the addEven 2 min read HTML DOM onafterprint Event The DOM onafterprint event occurs when a web page has started printing or if the print dialogue box has been closed. Supported Tags: <body> Syntax: HTML: <element onafterprint="myScript">JavaScript: object.onafterprint = function(){myScript};In JavaScript, using the addEventListener() me 1 min read Like