<bgsound>和<embed></embed>标签 頁面插入音樂

■ <BGSOUND> 是用以插入背景音乐,但只适用於 IE,其参数设定不多。
<BGSOUND src="liberation.mp3"; autostart=true loop=infinite>

src="your.mid"
设定 midi 或者是 mp3 档案及路径,可以是相对或绝对。
autostart=true
是否在音乐档传完之後,就自动播放音乐。true 是,false 否 (内定值)。
loop=infinite
是否自动反覆播放。LOOP=2 表示重复两次,Infinite 表示重复多次。

■ <embed>:

  <embed> 是用来插入各种多媒体,格式可以是 midi、wav、aiff、au 等等,netscape 及 新版的 ie 都支持。其参数设定较多。如下下

  <embed src="your.mid" autostart="true" loop="true" hidden="true">

src="your.mid"
设定 midi 档案及路径,可以是相对或绝对。
autostart=true
是否在音乐档下载完之后就自动播放。true 是,false 否 (内定值)。
loop="true"
是否自动反复播放。loop=2 表示重复两次,true 是, false 否。
hidden="true"
是否完全隐藏控制画面,true 为是,no 为否 (内定)。
starttime="分:秒"
设定歌曲开始播放的时间。如 starttime="00:30" 表示从第30秒处开始播放。
volume="0-100"
设定音量的大小,数值是0到100之间。内定则为使用系统本身的设定。
width="整数" 和 high="整数"
设定控制面板的高度和宽度。(若 hidden="no")
align="center"
设定控制面板和旁边文字的对齐方式,其值可以是 top、bottom、center、baseline、 left、right、texttop、middle、absmiddle、absbottom
controls="smallconsole"
设定控制面板的外观。预设值是 console。
console 一般正常面板   
smallconsole 较小的面板   
playbutton 只显示播放按钮   
pausecutton 只显示暂停按钮   
stopbutton 只显示停止按钮   
volumelever 只显示音量调节按钮

实例:

   1. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
   2. <html xmlns="http://www.w3.org/1999/xhtml">
   3. <head>
   4. <meta http-equiv="content-type" content="text/html; charset=gb2312" />
   5. <title>无标题文档</title>
   6. </head>
   7.
   8. <body>
   9. <bgsound src="http://sj.cpgl.net/sjbbs/midi/md01.mid " autostart=true loop=infinite>
  10. </body>
  11. </html>

复制代码

   1. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
   2. <html xmlns="http://www.w3.org/1999/xhtml">
   3. <head>
   4. <meta http-equiv="content-type" content="text/html; charset=gb2312" />
   5. <title>无标题文档</title>
   6. </head>
   7.
   8. <body>
   9. <embed src="http://www.bricklin.cn/zly/theone/2.wma" width="0" height="0"></embed>
  10. </body>
  11. </html>

当bgsound出现在iframe框架页面内时,如果框架页面内的背景音乐正在加载或正在播放

  当移除这个iframe框架时,该背景音乐仍然继续播放,而且窗口最小化后仍然播放

  直到音乐自然播放完毕或窗口关闭时停止(不会循环播放)。

  无论bgsound标签的loop属性设置如何,音乐只会播放一次。

  演示代码如下:

  <iframe id=bgmusic width=30 height=20></iframe>

  <script language=javascript>

  function window.onload(){

  var bghtml='sound<bgsound src="http://clearsky.gougou.cc/xiaonei/music.asp" loop="-1">';

  bgmusic.document.body.innerHTML=bghtml;

  document.all.bgmusic.removeNode();

  }

  </script>

多一分冷靜,少一分浮躁
原文地址:https://www.cnblogs.com/AnnyGird-LiMing/p/4873726.html