當媒體資料在 HTML 中載入時執行指令碼文件?
當媒體資料載入後,使用 onloaddata 事件來執行指令碼。嘗試執行以下程式碼來實現 onloaddata 事件 -
示例
當影片載入後,以下程式碼生成一個警報框 -
<!DOCTYPE html> <html> <body> <video controls onloadeddata = "display()"> <source src = "/html5/foo.ogg" type = "video/ogg" /> <source src = "/html5/foo.mp4" type = "video/mp4" /> Your browser does not support the video element. </video> <script> function display() { alert("Loaded!"); } </script> </body> </html>
廣告