在 HTML 中執行指令碼,當媒體被使用者或程式暫停時如何操作?
onpause 屬性會在媒體暫停時觸發。您可以嘗試執行以下程式碼來實現 onpause 屬性 −
示例
<!DOCTYPE html>
<html>
<body>
<h2 id = "test">Play</h2>
<video id = "myid" width = "320" height = "176" controls onpause = "myFunction()">
<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 myFunction() {
document.getElementById("test").innerHTML = "Media paused!";
}
</script>
</body>
</html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP