ITeye博客

网页嵌入mp3音乐

submaze · 2014-05-29 16:05 · Web开发 · Web前端 · Markdown



<!--声音-->
<audio id="v1" controls="controls" height="100" width="100" style=" display:none">
	<source src="music.mp3" type="audio/mp3" />
  <source src="song.ogg" type="audio/ogg" />
  <embed height="100" width="100" src="music.mp3" />
</audio>

<script>
var myVideo=document.getElementById("v1");

function playVid()
  {
  	myVideo.play();
  }
function pauseVid()
  {
  	myVideo.pause();
  }

</script>

<button onClick="playVid()">播放</button>
<button onClick="pauseVid()">暂停</button>


参考文档: HTML5标签介绍: http://www.w3school.com.cn/tags/html_ref_audio_video_dom.asp 音频播放介绍 http://www.w3school.com.cn/html/html_audio.asp

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。