English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The src attribute reflects the value of the src attribute of the HTML media element, which indicates the URL of the media resource to be used in the element.
HTML Audio/Video DOM Reference Manual
Change video source:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/video src attribute usage-Basic Tutorial(oldtoolbag.com)</title> </head> <body> <button onclick="changeSource()" type="button">Change video source</button> <br> <video id="video1" controls="controls" autoplay="autoplay"> <source id="mp4_src" src="mov_bbb.mp4" type="video/mp4"> <source id="ogg_src" src="mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> myVid=document.getElementById("video1"); function changeSource() { isSupp=myVid.canPlayType("video/mp4"); if (isSupp=="") { myVid.src="movie.ogg"; } else { myVid.src="movie.mp4"; } myVid.load(); } </script> </body> </html>Test to see ‹/›
src attribute sets or returns audio/Current source of the video.
Source is audio/Actual location of the video file (URL)
IEFirefoxOperaChromeSafari
Internet Explorer 10, Firefox, Opera, Chrome, and Safari support the src attribute.
Note:Internet Explorer 9 and earlier versions do not support the src attribute.
Set src attribute:
audio|video.src=URL
Return src attribute:
audio|video.src
Value | Description |
---|---|
URL | Specified audio/URL of the video source. Possible values:
|
Return value: | String value, the current audio/Video Source. |
---|