HTMLMediaElement.src
HTMLMediaElement.src
属性反映HTML媒体元素的src
属性的值,该属性指示要在元素中使用的媒体资源的URL。Note: 了解此元素中当前正在使用的媒体资源的URL的最佳方法是查看 currentSrc
属性的值,该属性还考虑从 HTMLSourceElement
(en-US) (代表 <source>
元素)中提供的列表中选择最佳或首选媒体资源
Syntax
var mediaUrl = HTMLMediaElement.src;
Value
一个USVString
对象,包含要在元素中使用的媒体资源的URL;此属性反映HTML元素的src
属性的值。
Example
var obj = document.createElement('video');
console.log(obj.src); // ""
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard HTMLMediaElement.src |
Living Standard | No change from HTML5 |
HTML5 HTMLMediaElement.src |
Recommendation | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
- The interface defining it,
HTMLMediaElement
.