Playing audio after the page loads in html

后端 未结 4 729
日久生厌
日久生厌 2020-12-15 08:27

I inserted the audio in html. But the audio gets started before the entire page loads. I want the audio to be played after the entire page gets loaded.

<         


        
4条回答
  •  青春惊慌失措
    2020-12-15 09:02

    You're going to need JavaScript for that. Remove the autoplay attribute:

    
    

    and add a script like this:

    window.onload = function() {
        document.getElementById("my_audio").play();
    }
    

    Or if you use jQuery:

    $(document).ready(function() {
        $("#my_audio").get(0).play();
    });
    

提交回复
热议问题