Get the audio preload information:
var x = document.getElementById("myAudio").preload;
Click the button to return the value of the preload attribute of the audio.
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls preload="none"> <source src="sound.ogg" type="audio/ogg"> <source src="sound.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>/*from w w w . j a va 2 s.c om*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myAudio").preload; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The preload
property sets or gets the preload attribute of an <audio> element.
The preload attribute provides a hint to the browser.
This attribute may be ignored.
The preload attribute is ignored if the autoplay attribute is present.
Property Values
Value | Description |
---|---|
auto | load the entire audio when the page loads |
metadata | load only metadata when the page loads |
none | should NOT load the audio when the page loads |
The preload
property returns a String.
Possible return values are