在 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>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
安卓
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP