首頁  >  文章  >  web前端  >  當HTML中的檔案不可用時執行腳本?

當HTML中的檔案不可用時執行腳本?

王林
王林轉載
2023-09-19 21:37:02531瀏覽

當HTML中的檔案不可用時執行腳本?

當檔案在 HTML 中不可用或為空時,使用 HTML 中的 onemptied 屬性來執行腳本。

範例

您可以嘗試執行以下程式碼來實作 onemptied 屬性 -

<!DOCTYPE HTML>
<html>
   <body>
      <video width = "300" height = "200" controls onemptied ="display()">
         <source src = "/html5/foo.ogg" type = "video/ogg" />
         Your browser does not support the video element.
      </video>
      <script>
         function display()
         {
            alert ("Sorry! Empty playlist!");
         }
      </script>
   </body>
</html>

以上是當HTML中的檔案不可用時執行腳本?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除