Latest web development tutorials

HTML Audio / Video DOM src attribute

HTML audio / video Tag Reference HTML Audio / Video DOM Reference

Examples

Change video sources:

myVid=document.getElementById("video1");
myVid.src="movie.ogg";

try it"

Definition and Usage

src property sets or returns the audio / video source current.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, Opera, Chrome and Safari support the src attribute.

Note: 9 and earlier versions of Internet Explorer does not support the src attribute.


grammar

Setting the src attribute:

audio|video .src= URL

Back src attribute:

audio|video .src

Property Value

描述
URL 规定音频/视频来源的 URL。

可能的值:

  • 绝对 URL - 指向另一个网站(比如 src="http://www.example.com/movie.ogg")
  • 相对 URL - 指向网站内的一个文件(比如 src="movie.ogg)

technical details

返回值: 字符串值,当前的音频/视频来源。


HTML audio / video Tag Reference HTML Audio / Video DOM Reference