Javascript DOM HTML Video controls Property enable and disable

Introduction

Enable, disable and check controls status:

View in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="100" height="100">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video><br>
<p id="demo"></p>
<button onclick="enableControls()" type="button">Enable controls</button>
<button onclick="disableControls()" type="button">Disable controls</button>
<button onclick="checkControls()" type="button">Check controls status</button>

<script>
var x = document.getElementById("myVideo");

function enableControls() {/*  w ww.ja v a  2s.c  o  m*/
  x.controls = true;
  x.load();
}

function disableControls() {
  x.controls = false;
  x.load();
}

function checkControls() {
  document.getElementById("demo").innerHTML =x.controls;
}
</script>

</body>
</html>



PreviousNext

Related