此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

HTMLMediaElement.currentSrc

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

HTMLMediaElement.currentSrc 属性包含所选媒体源的绝对 URL 路径。例如当程序会根据用户显示器分辨率选择不同媒体文件时会用到这个属性,显然它是只读的。当 networkState 值为 EMPTY 时,本属性值为空字符串(empty string).

语法

var mediaUrl = audioObject.currentSrc;

一个 DOMString 对象包含所选媒体源的绝对 URL 路径。当 networkState == EMPTY 时,其值为空字符串(empty string); 否则,它会是 HTMLSourceElement 所包含媒体列表中的一个,或者是 <source> 标签的 src 值。

示例

js
var obj = document.createElement("video");
console.log(obj.currentSrc); // ""

规范

Specification
HTML
# dom-media-currentsrc-dev

浏览器兼容性

参考