<audio id="play" controls="controls" loop="loop"> <source src="horse.mp3" type="audio/mpeg"> </audio>浏览器出现:Uncaught (in promise) DOMException: play() failed because the user didn't intera…
最近在开发一个网站时,有个需要是 如果有新预警信息要在网页中播放提示音.页面打开会请求是否有新信息,有则播放提示音.在Chrome的最新浏览器中,播放会报错,控制台显示Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.搜索发现Chrome 66为了避免标签产生随机噪音禁止没有交互前使用js进行播放.最后解决方案为 在chrome地址栏…