javascript - 如何在网站中插入音乐?

标签 javascript html css xhtml

<分区>

Possible Duplicate:
Integrate a mp3 player into a page with no reloading issue

我有一个有 10 个网页的网站,我想在这个网站中插入一首自动播放的歌曲。

但是我希望当我点击这个网站的另一个网页时音乐不会停止。

这是一种不使用 iframe 或 flash 的方法吗?

最佳答案

编辑:我没有完整阅读您的问题。除非您使用框架或 Ajax 进行导航(如在 Gmail 或 New Twitter 中),否则这是不可能的。

Old method

<BGSOUND SRC="aladdin.mid" LOOP=10>

Or use HTML 5

<audio autoplay id="bgsound">
 <source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.mp4"
         type="audio/mp4">
 <source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.oga"
         type="audio/ogg; codecs=vorbis">
 <p>Your user agent does not support the HTML5 Audio element.</p>
</audio>
<button type="button"
        onclick="document.getElementById('bgsound').pause();">
  Stop background sound
</button>

<p>
You'll probably annoy your readers if you use background sounds in documents.
</p>

关于javascript - 如何在网站中插入音乐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4533874/

上一篇:jquery - 将值插入隐藏和数据库问题?

下一篇:javascript - 不能居中div

相关文章:

javascript - 鼠标移开后 jQuery 工具提示悬停仍在运行

javascript - 谷歌地图设置位置?

html - 了解为什么表格单元格不包含其 100% 高度内容

css - 如何用 ngStyle 覆盖子元素样式

html - 如何为具有各种背景图像并在其上放置内容的布局正确构建 HTML?

javascript - 使用 javascript 和 css : iding/showing fields dynamically doesn't work. 制作动态表单时出现问题 你能帮帮我吗?

html - 即使高度设置为 100%,当我缩小浏览器大小时,文本会与背景重叠吗?

javascript - 如何创建显示隐藏导航菜单

html - 美丽杰基尔主题 : How to modify the page title color in CSS?

javascript - jQuery + 测试元素值(扩展)