English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The currentSrc attribute contains the absolute URL path of the selected media source. For example, this attribute is often used when the program selects different media files based on the user's screen resolution, and it is obviously read-only. When the networkState value is EMPTY, the value of this attribute is an empty string (empty string).
HTML Audio/Video DOM Reference Manual
Get the current video URL:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/video currentSrc attribute usage-Basic Tutorial(oldtoolbag.com)</<title> </<head> <body> <button onclick="getVid()" type="button">Get the current video URL: </button> <br> <video id="video1" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> myVid=document.getElementById("video1"); function getVid() { alert(myVid.currentSrc); } </script> </body> </html>Test to see ‹/›
The currentSrc property returns the current audio/The URL of the video.
If audio is not set/If a video is returned, an empty string is returned.
Note: This property is read-only.
Tip: Use the src attribute to set the URL of the video file.
IEFirefoxOperaChromeSafari
All major browsers support the currentSrc property.
Note:Internet Explorer 8 and earlier versions do not support this property.
audio|video.currentSrc
Return value: | A string value representing the audio/The current URL of the video. |
---|