媒體在 HTML 中開始播放時執行指令碼?
使用 onplaying 屬性來讓使用者知道音訊/影片開始播放。
示例
你可以嘗試執行以下程式碼來了解如何在媒體開始播放時執行指令碼 −
<!DOCTYPE html> <html> <body> <video id = "myid" width = "350" height = "200" controls onplaying = "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("Video started playing!"); } </script> </body> </html>
廣告