Video src attribute
Definition and usage
src
The attribute sets or returns the value of the video's src attribute.
src
The attribute specifies the location (URL) of the video file.
Example
Example 1
Change the video URL:
document.getElementById("myVideo").src = "beijing.mp4";
Example 2
Get the video URL:
var x = document.getElementById("myVideo").src;
Syntax
Return the src attribute:
videoObject.src
Set the src attribute:
videoObject.src = URL
Attribute value
Value | Description |
---|---|
URL |
Specifies the URL of the video file. Possible values:
|
Technical Details
Return Value: | String value representing the URL of the video file. Returns the entire URL, including the protocol (such as http://). |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 9.0 | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <video> src Attribute