Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Video src Property

Video src property

Video Object Reference The Video object

Example

Change the URL of the video:

document.getElementById("myVideo").src = "mov_bbb.ogg";

Try it »


Definition and Usage

The src property sets or returns the value of the video's src attribute.

The src property describes the location (URL) of the video file.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the src property, but not all browsers support the specified file format.

Note: Internet Explorer 8 and earlier IE versions do not support


Syntax

Return the src attribute:

videoObject

.src

Set the src attribute:

videoObject

.src=

URL

Attribute values

Value Description
URL

Specifies the URL of the video source.

Possible values:

  • Absolute URL - points to another website (e.g. src="http://example.com/movie.ogg")
  • Relative URL - Points to a file within the website (e.g. src="movie.ogg")
  • |

    Technical Details

    Return Value: A string representing the URL of the video file. Returns the actual URL including the protocol part (e.g. http://)

    More examples

    Example

    Get the URL of the video:

    var x = document.getElementById("myVideo").src;

    x

    The output is:

    https://www.example.com/jsref/movie.ogg

    Try it »


    Related pages

    HTML Reference Manual: HTML


    Video Object Reference The Video object