How to use html+js to write a page with automatic sound

How to use html+js to write a page with automatic sound

Don't say anything, just go to the code.

<html><body><h1>It works!</h1>
  <audio src="" id="audio" ></audio>
</body> 
<script>
var x = document.getElementById("audio");
  x.src="mp3路径.mp3";
x.play(); 
</script>
</html>

Use the above html to automatically sound when entering the page. If you open it in Goole, remember to open the permission to make a sound, and don't step on the pit again.

 

 

Welcome to follow us!

Guess you like

Origin blog.csdn.net/qq_39046854/article/details/107569030