I'm trying to work out how to get the onabort
event of an image element to work. From reading the docs it's meant to fire when a loading page is stopped either from clicking the stop button or firing the stop event.
I can get the following code snippet to work in IE but not in any of the other browsers. What am I doing wrong?
<html>
<head>
</head>
<开发者_开发知识库body>
<script type="text/javascript">
function load(e) {
alert('img loaded');
}
function onaborthandle() {
alert('on abort hadnle');
}
function abort() {
if (window.stop) {
window.stop();
}
else {
document.execCommand("Stop", false);
}
}
</script>
<img id="testimg" onabort="alert('abort inline');" />
<script type="text/javascript">
var img = document.getElementById('testimg');
img.onload = load;
img.src = 'http://sstatic.net/so/img/logo.png';
abort();
</script>
</body>
</html>
nothing is wrong, onabort and onerror are not supported in ff, and apparently in chrome too. although I read somewhere that the event will not work on local system files, but on files hosted on the web, not sure about it.
The onabort event handler is not supported in Chrome, Firefox, Opera, or Safari; it is only supported in Internet Explorer.
Credit: W3Schools
The onabort
event is only supported by Internet Explorer and Edge.
精彩评论