本文介绍了在隐藏标签中播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在网页上设置声音.
I am trying to set sound on web page.
我找到了此代码.当 div 可见时,它是工作代码,但我想隐藏起来并工作.在这种情况下,它不起作用,因为它已被 style 属性隐藏.如何使其不可见并同时播放声音?
I found this code. It is working code when the div is visible but I want to be hidden and working. In this case it is not working because it is hidden with style attribute. How to make it not visible and playing sound at the same time ?
<div style="display:none"> <embed src="sound.mp3"/> </div> 推荐答案我同意以上评论中的观点-这个可以令人讨厌.我们只能希望您为用户提供关闭音乐的选项.
I agree with the sentiment in the comments above — this can be pretty annoying. We can only hope you give the user the option to turn the music off.
但是...
audio { display:none;} <audio autoplay="true" src="upload.wikimedia/wikipedia/commons/c/c8/Example.ogg">
css隐藏 audio 元素,然后 autoplay ="true" 自动播放它.
The css hides the audio element, and the autoplay="true" plays it automatically.
更多推荐
在隐藏标签中播放声音
发布评论