onseek Event | DHTML中文手册 |
Fires whenever a seek operation is performed on the element.
dhtml语法
Inline HTML <ELEMENT onseek = "handler" ... > All platforms Event property object.onseek = handler JScript only object.onseek = GetRef("handler") Visual Basic Scripting Edition (VBScript) 5.0 or later only Named script <SCRIPT FOR = object EVENT = onseek> Internet Explorer only
Event Information
Bubbles No Cancels No To invoke Open a page in the browser that contains a media file affected by introduction to html+time. call one of the seek methods, such as seekto, seektoframe or seekActiveTime. Default action Calls the associated event handler.
Available Properties
DHTML代码范例
This example demonstrates how to use the onseek event. The onseek event fires when either the seekto, seektoframe or seekactivetime method is called upon a media object. before validating and implementing the value to seek, make sure the object is active to avoid receiving an error message. in this example, if the object is not active the beginelement method is called to restart the object, followed by the request to seek. choose a method to use from the drop-down menu and enter a value in the input box. click the button labelled 'click to seek'. the media object seeks to the value entered and pauses. click the 'resume' button to resume the video from that point.
<html xmlns:t= "urn:schemas-microsoft-com:time"> <HEAD> <?IMPORT namespace="t" implementation="#default#time2"> <STYLE> .time{behavior:url(#default#time2)} </STYLE> <SCRIPT> function doSeek(){ var maxlength; //What is the maximum value that the user can input. //There are a total of 597 frames in the video with duration of 20.06205 //seconds. switch(oMethod.options.selectedIndex){ case 0: maxlength = oMedia.mediaDur; break; case 1: maxlength = oMedia.mediaDur; break; case 2: maxlength = 598; break; } //Is media object active? //Yes, continue and do seek. //No, restart element using the beginElement method. if(!oMedia.currTimeState.isActive){ oMedia.beginElement(); } //Is user input valid and within the media's duration boundaries? if(isFinite(seekInput.value) && seekInput.value > 0 && seekInput.value < maxlength){ switch(oMethod.options.selectedIndex){ case 0: oMedia.seekTo(1, seekInput.value); break; case 1: oMedia.seekActiveTime(seekInput.value); break; case 2: oMedia.seekToFrame(seekInput.value); break; } oMedia.pauseElement(); }else{ //Input is not valid, alert user to re-enter choice. switch(oMethod.options.selectedIndex){ case 0: alert("Please enter a valid integer. Value must be greater" + " than 0 and less than " + oMedia.mediaDur + "."); break; case 1: alert("Please enter a valid integer. Value must be greater" + " than 0 and less than " + oMedia.mediaDur + "."); break; case 2: alert("Please enter a valid integer. Value must be greater" + " than 0 and less than 597."); break; } seekInput.focus(); } } function fn_doseek(flag){ //Is the function being called from the onseek event? if(flag){ resumeBtn.style.visibility = "visible"; seekBtn.style.visibility = "hidden"; restartBtn.style.visibility = "hidden"; //Function is being called from the resumeBtn. }else{ resumeBtn.style.visibility = "hidden"; seekBtn.style.visibility = "visible"; restartBtn.style.visibility = "visible"; oMedia.resumeElement(); seekInput.value=""; } } </SCRIPT> </HEAD> <BODY> <CENTER> <B>Media timer:</B> <SPAN id="Timer2" class="time" dur=".01" repeatCount="indefinite" fill="hold" onrepeat="innerText=parseInt(oMedia.currTimeState.activeTime);">0</SPAN> <BR><BR> <t:video onseek="fn_doseek(true);" style="width:175px; height:150px;" id="oMedia" src="../../common/samples/author/behaviors/media/movie.avi"/> <BR><BR> <B>Choose method:</B> <SELECT name="oMethod"> <OPTION value="seekTo" selected>seekTo</OPTION> <OPTION value="seekActiveTime">seekActiveTime</OPTION> </SELECT> <BR> <B>Time value to seek in object's timeline</B>: <INPUT type="text" value="" name="seekInput" size="3"/> seconds <BR><BR> <BUTTON id="seekBtn" onclick="doSeek();">Click to seek</BUTTON> <BUTTON id="resumeBtn" onclick="fn_doseek(false);" style="visibility:hidden;">Resume</BUTTON> <BUTTON id="restartBtn" onclick="oMedia.beginElement()">Restart</BUTTON> </CENTER> </BODY> </HTML>
是否符合公共标准
This event is a Microsoft extension to Synchronized Multimedia Integration Language (SMIL) .
Applies To
t:TRANSITIONFILTER, t:ANIMATION, t:AUDIO, t:EXCL, t:IMG, t:MEDIA, t:PAR, t:REF, t:SEQ, time2, t:VIDEO
更多语法参考
Introduction to HTML+TIME