HTMLMediaElement: src property
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
TheHTMLMediaElement.src
property reflects the value ofthe HTML media element'ssrc
attribute, which indicates the URL of a mediaresource to use in the element.
Note:The best way to know the URL of the media resource currentlyin active use in this element is to look at the value of thecurrentSrc
attribute, which also takesinto account selection of a best or preferred media resource from a list provided inanHTMLSourceElement
(which represents a<source>
element).
Value
A string containing the URL of a media resource to use in theelement; this property reflects the value of the HTML element'ssrc
attribute.
Examples
js
const obj = document.createElement("video");console.log(obj.src); // ""
Specifications
Specification |
---|
HTML # dom-media-src |
Browser compatibility
See also
HTMLMediaElement
: Interface used to define theHTMLMediaElement.src
property