请问谁知道怎么控制web页面的背景音乐?

white_dog 2002-07-16 09:07:40
如背景音乐的播放,暂停,停止等。
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
white_dog 2002-07-16
  • 打赏
  • 举报
回复
有了:)

<script>
function ctbg(music)
{
if (bgmusic.src!="")
{bgmusic.src=""}
else
{bgmusic.src=music}
}
</script>
<bgsound src="trippygaia1.mid" loop="-1" id="bgmusic">
<a href="#" onclick=ctbg('trippygaia1.mid')>关闭/播放音乐</a>
meizz 2002-07-16
  • 打赏
  • 举报
回复
给你一个相关的代码:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>每次都不一样的背景音乐</title>
</head>

<body>

<SCRIPT language="JavaScript"><!--
var sound1="song1.mid"
var sound2="song2.mid"
var sound3="song3.mid"
var sound4="song4.mid"
var sound5="song5.mid"
var sound6="song6.mid"
var sound7="song7.mid"
var sound8="song8.mid"
var sound9="song9.mid"
var sound10="song10.mid"
var x=Math.round(Math.random()*9)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else if (x==4) x=sound5
else if (x==5) x=sound6
else if (x==6) x=sound7
else if (x==7) x=sound8
else if (x==8) x=sound9
else x=sound10
if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+x+'"'+' loop="infinite">')
else
document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')
//--></SCRIPT>
</body>

</html>

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧