เหตุการณ์ onseeking

คำนิยามและวิธีใช้

เหตุการณ์ onseeking จะเกิดขึ้นเมื่อผู้ใช้เริ่มเคลื่อนไหว/กระโดดไปยังตำแหน่งใหม่ของเสียง/วิดีโอ

คำแนะนำ:เหตุการณ์ onseeking กับ เหตุการณ์ onseekedตรงกันข้าม

คำแนะนำ:ใช้งานเสียง/วิดีโอโอปเจ็กต์ ตัวแปร currentTimeGet the current playback position.

ตัวอย่าง

Execute JavaScript when the user starts moving/jumping to a new position in the video:

<video onseeking="myFunction()">

ทดลองด้วยตัวเอง

There are more TIY examples at the bottom of the page.

Syntax

In HTML:

<element onseeking="myScript">

ทดลองด้วยตัวเอง

In JavaScript:

object.onseeking = function(){myScript};

ทดลองด้วยตัวเอง

In JavaScript, use the addEventListener() method:

object.addEventListener("seeking", myScript);

ทดลองด้วยตัวเอง

Note:Internet Explorer 8 or earlier versions do not support addEventListener() method.

Technical details

Bubble: Not supported
Cancelable: Not supported
Event type: Event
สนับสนุน HTML tag: <audio> และ <video>
DOM version: Level 3 Events

สนับสนุนโดยบราวเซอร์

ตัวเลขในตารางบ่งชี้เวอร์ชั่นบราวเซอร์ที่สนับสนุนกิจกรรมนี้อย่างเต็มที่

กิจกรรม Chrome IE Firefox Safari Opera
onseeking สนับสนุน 9.0 สนับสนุน สนับสนุน สนับสนุน

ตัวอย่างเพิ่มเติม

ตัวอย่าง

ตัวอย่างนี้แสดงถึงความแตกต่างระหว่างกิจกรรม onseeking และ onseeked:

<video onseeking="myFunction()" onseeked="mySecondFunction()">

ทดลองด้วยตัวเอง

ตัวอย่าง

เมื่อผู้ใช้เริ่มกระโดดไปยังตำแหน่งใหม่ ใช้คุณสมบัติ currentTime ของ Video object แสดงตำแหน่งเวลาปัจจุบัน:

// ดึง element <video> ที่ id="myVideo"
var x = document.getElementById("myVideo");
// และ attach กิจกรรม seeking ให้กับ <video> และ ทำงานฟังก์ชันเมื่อการ seek จะเริ่มต้น
x.addEventListener("seeking", myFunction); 
function myFunction() {
  // ใน element <p> ที่ id="demo" แสดงตำแหน่งเวลาของวิดีโอ
  document.getElementById("demo").innerHTML = x.currentTime; 
}

ทดลองด้วยตัวเอง

ตัวอย่าง

ปฏิบัติ JavaScript ขณะที่ผู้ใช้เริ่มเคลื่อนไป/กระโดดไปยังตำแหน่งใหม่ของแสงเสียง:

<audio onseeking="myFunction()">

ทดลองด้วยตัวเอง