I'm trying to make a backup script but it doesn't want to register the onabort nor abort events. When I purposefully mess up my src link to make the onabort callback run it doesn't work.
document.getElementById("test").addEventListener('onabort',() =>{
prompt('works:${y}')
})
document.getElementById("test").src="linol.js"
<script id="test" ></script>
CodePudding user response:
Event onabort
is only for media elements. You're looking for onerror
, which fires when a script fails to load:
<script id="test" src="wae7r8456fs4786f5hdummynothingnope