❮ HTML Audio/Video Dom tham khảo
Thí dụ
Cảnh báo rằng video đã bị tạm dừng:
var vid = document.getEuityById ["myVideo"]; vid.onpause = function [] {& nbsp; & nbsp; & nbsp; cảnh báo ["video đã bị tạm dừng"];};
vid.onpause = function[] {
alert["The video has been paused"];
};
Hãy tự mình thử »
Thêm ví dụ "hãy thử nó" dưới đây.
Định nghĩa và cách sử dụng
Sự kiện tạm dừng xảy ra khi âm thanh/video được người dùng hoặc lập trình tạm dừng.
Mẹo: Sự kiện chơi xảy ra khi âm thanh/video đã được bắt đầu hoặc không còn bị tạm dừng nữa. The play event occurs when the audio/video has been started or is no longer paused.
Hỗ trợ trình duyệt
Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ sự kiện.
tạm ngừng | Đúng | 9.0 | Đúng | Đúng | Đúng |
Cú pháp
Trong HTML:
Thử nó
Trong JavaScript:
Audio | Video.Onpause = function [] {myScript}; thử nó
Trong javascript, sử dụng phương thức addEventListener []:
Audio | Video.AddeventListener ["Tạm dừng", MyScript]; thử nó
Chi tiết kỹ thuật
và |
Âm thanh, video |
Nhiều ví dụ hơn
Thí dụ
Thông báo rằng âm thanh đã bị tạm dừng:
var aud = document.getEuityById ["myAudio"]; aud.onpause = function [] {& nbsp; & nbsp; & nbsp; cảnh báo ["âm thanh đã bị tạm dừng"];};
aud.onpause = function[] {
alert["The audio has been paused"];
};
Hãy tự mình thử »
❮ HTML Audio/Video Dom tham khảo
Sự kiện Sự kiện này được gửi một khi phương thức Sự kiện này không thể hủy bỏ và không bong bóng. Sử dụng tên sự kiện trong các phương thức như pause
được gửi khi yêu cầu tạm dừng một hoạt động được xử lý và hoạt động đã đi vào trạng thái tạm dừng của nó, phổ biến nhất là sau khi phương tiện truyền thông được tạm dừng thông qua một cuộc gọi đến phương thức pause[]
của phần tử.pause[]
trả về và sau khi thuộc tính paused
của phần tử truyền thông đã được thay đổi thành true
.Cú pháp
addEventListener[]
hoặc đặt thuộc tính Trình xử lý sự kiện.addEventListener['pause', [event] => {}];
onpause = [event] => { };
Loại sự kiện
Ví dụ
Các ví dụ này thêm một trình nghe sự kiện cho sự kiện pause
của HTMLMediaEleement, sau đó đăng một tin nhắn khi trình xử lý sự kiện đó đã phản ứng với việc bắn sự kiện.
Sử dụng addEventListener[]
:
const video = document.querySelector['video'];
video.addEventListener['pause', [event] => {
console.log['The Boolean paused property is now true. Either the ' +
'pause[] method was called or the autoplay attribute was toggled.'];
}];
Sử dụng thuộc tính Trình xử lý sự kiện
const video = document.querySelector['video'];
video.addEventListener['pause', [event] => {
console.log['The Boolean paused property is now true. Either the ' +
'pause[] method was called or the autoplay attribute was toggled.'];
}];
1:const video = document.querySelector['video'];
video.onpause = [event] => {
console.log['The Boolean paused property is now true. Either the ' +
'pause[] method was called or the autoplay attribute was toggled.'];
};
Thông số kỹ thuật
HTML Standard # Event-Media-Pause # event-media-pause |
HTML Tiêu chuẩn # Handler-OnPause # handler-onpause |
Tính tương thích của trình duyệt web
Bảng BCD chỉ tải trong trình duyệt
- Sự kiện HTMLMediaEleement
2const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện htmlmediaEleement
3const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện HTMLMediaEleement
4const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện HTMLMediaEleement
5const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện htmlmediaEleement
6const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện HTMLMediaEleement
7const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện htmlmediaEleement
8const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện HTMLMediaEleement
9const video = document.querySelector['video']; video.addEventListener['pause', [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; }];
- Sự kiện HTMLMediaEleement
0const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện HTMLMediaEleement
1const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện htmlmediaEleement
2const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện HTMLMediaEleement
3const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện HTMLMediaEleement
pause
- Sự kiện htmlmediaEleement
5const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện htmlmediaEleement
6const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện HTMLMediaEleement
7const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện htmlmediaEleement
8const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };
- Sự kiện HTMLMediaEleement
9const video = document.querySelector['video']; video.onpause = [event] => { console.log['The Boolean paused property is now true. Either the ' + 'pause[] method was called or the autoplay attribute was toggled.']; };