我知道IE11是一款非常特别的浏览器。我不知道,audio.play()
不起作用。在任何现代浏览器中测试,这个简单的代码片段都有效。在IE11中测试,你听到沉默。对此有一个简单的解决方法吗?
function playAudio() {
var audio = document.querySelector('audio[src*="media"');
audio.play();
}
var button = document.querySelector('button');
button.addEventListener('click', playAudio);

@import url( "https://necolas.github.io/normalize.css/latest/normalize.css" );
body {
line-height: 2rem;
}
.button-container {
width: 200px;
float: left;
}
button {
cursor: pointer;
display: block;
margin: 80px auto;
}
p {
width: 200px;
float: left
}

<div class="button-container">
<button>Play Audio</button>
</div>
<p>
Click this button in any other browser but IE11 & below and it should work.<br>
<b>:(</b>
</p>
<audio src=
"http://vocaroo.com/media_command.php?media=s05tGWFyu2eb&command=download_wav"
>
</audio>
&#13;