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 GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
src

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见