JS網(wǎng)頁播放聲音實現(xiàn)代碼兼容各種瀏覽器
更新時間:2013年09月22日 15:33:15 作者:
JS網(wǎng)頁播放聲音有多種方法可以實現(xiàn),不過兼容各種瀏覽器的就沒有幾個了,不過本文的這個示例或許對大家有所幫助
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SwfObject2.2Demo</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashvars = {
};
var params = {
wmode: "transparent"
};
var attributes = {};
swfobject.embedSWF("sound.swf", "sound", "1", "1", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
function play(c) {
var sound = swfobject.getObjectById("sound");
if (sound) {
sound.SetVariable("f", c);
sound.GotoFrame(1);
}
}
</script>
</head>
<body>
<div id="sound">
</div>
<input type="button" value="播放" onclick="play('msg.mp3')" />
</body>
</html>
需要的引入文件,在js特效文件夾里面
相關(guān)文章
微信小程序?qū)崿F(xiàn)點擊圖片旋轉(zhuǎn)180度并且彈出下拉列表
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)點擊圖片旋轉(zhuǎn)180度并且彈出下拉列表,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-11-11
JavaScript列表框listbox全選和反選的實現(xiàn)方法
這篇文章主要介紹了JavaScript列表框listbox全選和反選的實現(xiàn)方法,涉及javascript操作列表框listbox的技巧,非常具有實用價值,需要的朋友可以參考下2015-03-03
JavaScript實現(xiàn)動態(tài)高度過渡的3種方式總結(jié)
這篇文章主要為大家詳細介紹了JavaScript實現(xiàn)動態(tài)高度過渡的3種方式,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2024-01-01

