Home > Web Front-end > H5 Tutorial > body text

Detailed explanation of HTML5 using DOM for custom control sample code

黄舟
Release: 2017-03-20 15:50:39
Original
1791 people have browsed it

Although

HTML5 videos can use controls to display controls, and control playback, pause, etc., different browsers may display different effects. Let’s share with you how to use it. Dom is used to perform some customized operations and control

Although HTML5 videos can use controls to display controls and control playback, pause, etc., different browsers may display different effects, so many times we need Use Dom to perform some customized operations and controls. Below is a small example.
Of course the effect is not very beautiful. If you want it to look good, you can set the css style yourself.

<div id="video_div" style="text-align:center;"> 
<button onclick="playPause()">播放/暂停</button> 
<button onclick="toBig()">大</button> 
<button onclick="toNormal()">中</button> 
<button onclick="toSmall()">小</button> 
  
<video id="myVideo" width="500" height="250" style="margin-top:15px;"> 
<source src="demo.mp4" type="video/mp4" /> 
<source src="demo.ogg" type="video/ogg" /> 
您的浏览器不支持此HTML5 视频标签。 
</video> 
</div>
Copy after login
<script type="text/javascript"> 
var myVideo=document.getElementById("myVideo"); 
function playPause() 
{ 
if (myVideo.paused) 
myVideo.play(); 
else 
myVideo.pause(); 
} 
function toBig() 
{ 
myVideo.width=560; 
} 
function toNormal() 
{ 
myVideo.width=420; 
} 
function toSmall() 
{ 
myVideo.width=320; 
} 
</script>
Copy after login

It should be noted that among all properties, only the videoWidth and videoHeight properties are immediately available.

The other properties are not available until the video's metadata has been loaded.

The above is the detailed content of Detailed explanation of HTML5 using DOM for custom control sample code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!