首页 > 文章列表 > 在JavaScript中,"abort"事件的用途是什么?

在JavaScript中,"abort"事件的用途是什么?

483 2023-09-12

使用abort 事件来中止图片的加载。您可以尝试运行以下代码来学习如何在JavaScript中实现中止事件。

示例

<!DOCTYPE html>
<html>
   <body>
      <script>
         function abortFunc() {
            alert('Error- Loading of the image aborted');
         }
      </script>
      <img src="/videotutorials/images/tutor_connect_home.jpg" onabort = "abortFunc()">
   </body>
</html>