HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> #myImg { display:block; margin-bottom:5px; width: 220px; height: 220px; border: 1px solid #8c8c8c; } </style> </head> <body> <img id="myImg"> <button onclick="startFunction()">Start download</button> <button onclick="stopFunction()">Stop download</button> <p><strong>Note</strong>: onabort function is not working in any modern web browser.</p> <script> var imgUrl= 'https://wikimass.com/myhouse.jpg'; var x = document.getElementsByTagName("img")[0]; function startFunction(){ document.getElementById("myImg").src = imgUrl; } function stopFunction(){ document.getElementById("myImg").src = ""; } function myFunction(){ // Not Triggering in any modern browser alert("Download aborted"); } x.onabort = myFunction; </script> </body> </html>
OUTPUT
×

Save as Private