Video controlsProperty

Video 对象参考手册Video Object

Example

Enable video controls:

document.getElementById("myVideo").controls=true;

Try it Yourself »

Definition and Usage

The controls property sets or returns whether the browser should display standard video controls.

This property reflects the <video> controls attribute.

When this attribute is present, it specifies that video controls should be displayed.

Video controls include:

  • Play
  • Pause
  • Progress bar
  • Volume
  • Fullscreen toggle (for video)
  • Subtitles (when available)
  • Tracks (when available)

Note:The <video> element is new in HTML5.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the controls attribute

Note:Internet Explorer 8 and earlier IE versions do not support the <video> element.


Syntax

Return the controls property:

videoObject.controls

Set the controls property:

videoObject.controls=true|false

Property Values

Value Description
true|false Describes whether video controls are displayed:
  • true - Specifies that controls should be displayed
  • false - Default. Specifies that controls should not be displayed

Technical Details

Return Value: A Boolean, returns true if video controls are displayed, otherwise returns false.
Default Value: false 


More Examples

Example

Check whether video controls are displayed:

var x = document.getElementById("myVideo").controls;
xThe output result is:
true

Try it Yourself »

Example

Enable, disable and detect the state of the controls:

var x = document.getElementById("myVideo"); function enableControls(){ x.controls = true; x.load(); } function disableControls(){ x.controls = false; x.load(); } function checkControls(){ alert(x.controls); }

Try it Yourself »

Related Pages

HTML Reference Manual:HTML <video> controls attribute


Video 对象参考手册Video Object Other Extensions