HTMLMediaElement:src 属性
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
HTMLMediaElement.src
属性反映 HTML 媒体元素的 src
属性的值,其指示要在元素中使用的媒体资源的 URL。
备注:
了解此元素当前正在使用的媒体资源的 URL 的最佳方法是查看 currentSrc
属性的值,该属性还考虑从 HTMLSourceElement
(代表 <source>
元素)中提供的列表中选择的最佳或首选媒体资源。
值
一个包含要在元素中使用的媒体资源的 URL 的字符串;此属性反映 HTML 元素的 src
属性的值。
示例
js
const obj = document.createElement("video");
console.log(obj.src); // ""
规范
Specification |
---|
HTML # dom-media-src |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
src |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
HTMLMediaElement
:用于定义HTMLMediaElement.src
属性的接口。