檔案在 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-Mar-2020

147 次瀏覽

啟動你的 職業

完成課程以獲得認證

開始
廣告
© . All rights reserved.