Video srcProperty

Video 对象参考手册Video Object

Example

Change the URL of the video:

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

Try it Yourself »

Definition and Usage

The src attribute sets or returns the value of the src attribute of the video.

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the src attribute, but not all browsers support the specified file formats.

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


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.html")

Technical Details

Return Value: A string representing the URL of the video file. Returns the full URL, including the protocol part (such as http://)


More Examples

Example

Get the URL of the video:

var x = document.getElementById("myVideo").src;
xThe output result is:
https://www.example.com/jsref/movie.ogg

Try it Yourself »


Related Pages

HTML Reference Manual:HTML <video> src Attribute


Video 对象参考手册Video Object Other Extensions