Home > Article > Web Front-end > html5 returns the attribute networkState of the current network status (activity) of audio/video
Example
Get the current network status of video:
myVid=document.getElementById("video1"); alert(myVid.networkState);
Definition and usage
networkState property returns audio/ The current network status (activity) of the video.
Browser support
All major browsers support the networkState attribute.
Note: This attribute is not supported in Internet Explorer 8 or earlier browsers.
Syntax
audio|video.networkState
Return value
Type | Description |
Numeric value |
represents the current network status of the audio/video element:
|
<!DOCTYPE html> <html> <body> <p> <button onclick="getNWState()" type="button">获得网络状态</button> </p> <video id="video1" controls="controls" autoplay="autoplay"> <source src="/kf51/demo/mov_bbb.mp4" type="video/mp4"> <source src="/kf51/demo/mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 video 标签。 </video> <script> var myVid = document.getElementById("video1"); function getNWState() { alert(myVid.networkState); } </script> </body> </html>
The above is the detailed content of html5 returns the attribute networkState of the current network status (activity) of audio/video. For more information, please follow other related articles on the PHP Chinese website!