HTML Audio嵌入不适用于Internet Explorer

时间:2015-05-27 17:08:56

标签: html5 audio

在我的网站上我放了音频。它在Chrome中运行良好,具有自动播放和循环,但在IE中它显示“发生未知错误”。音频文件是“ComicSans.mp3”,这是编码:

<body bgcolor="#5e54e8">    
<a class="GeneratedLink" href="http://georgeocodes.github.io/" target="_blank"">George O Codes</a>
<audio controls>
<audio src="ComicSans.mp3" controls autoplay loop> 
Your browser does not support the audio element.
</audio>
<marquee direction="right" scrollamount="3" behavior="scroll" style="color: #ffffff; font-size: 20px; font-family: Comic Sans MS; background-color: #5e54e8;">Lock your doors and hide your children. This is the invasion of Comic Sans.</marquee>
<marquee direction="right" scrollamount="3" behavior="scroll" style="color: #ffffff; font-size: 20px; font-family: Comic Sans MS; background-color: #5e54e8;">Lock your doors and hide your children. This is the invasion of Comic Sans.</marquee>
<marquee direction="right" scrollamount="3" behavior="scroll" style="color: #ffffff; font-size: 20px; font-family: Comic Sans MS; background-color: #5e54e8;">Lock your doors and hide your children. This is the invasion of Comic Sans.</marquee>
<marquee direction="right" scrollamount="3" behavior="scroll" style="color: #ffffff; font-size: 20px; font-family: Comic Sans MS; background-color: #5e54e8;">Lock your doors and hide your children. This is the invasion of Comic Sans.</marquee>
</body>

还有很多字幕标签,但我剪掉了大部分标签。

1 个答案:

答案 0 :(得分:0)

您对音频的代码无效。如果您选中HTML5 definition for the audio tag,则必须使用结束标记。它适用于Chrome和Firefox,但不适用于IE,因为每个浏览器都会解释无效代码:

<audio controls>
    <audio src="ComicSans.mp3" controls autoplay loop> 
    Your browser does not support the audio element.
</audio>

要解决此问题,只需删除第一个<audio controls>,声音即可在所有浏览器中使用:

&#13;
&#13;
<audio src="http://comicsanswillrule.github.io/ComicSans.mp3" controls autoplay loop> 
    Your browser does not support the audio element.
</audio>
&#13;
&#13;
&#13;