檔案在 HTML 中不可用時執行指令碼?


在 HTML 中使用 onemptied 屬性,可在 HTML 中檔案不可用或為空時執行指令碼。

示例

您可以嘗試執行以下程式碼來實現 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>

更新於: 03-03-2020

147 次瀏覽

開啟您的職業生涯

完成課程後獲得認證

開始
廣告
© . All rights reserved.