在我的CMS网站上,页面加载时我会自动弹出颜色框。通过在home.tpl文件中插入音频标签,我可以在用户单击我的网站主页时播放音频。使音频仅在颜色框弹出窗口关闭后才能播放。如何为此功能编写jquery。
colorbox popup
音频的代码<audio>
<source src="..." type="audio/mp3" />
</audio>
最佳答案
我已经通过更新如下所示的脚本来使其工作。
<audio id="playaudio">
<source src="catalog/view/theme/pav_cosmetics/media/intro.mp3" type="audio/mp3" />
</audio>
<script>
jQuery(document).ready(function(){
if (document.cookie.indexOf('visited=true') == -1) {
var expire = new Date();
expire = new Date(expire.getTime() + 7776000000);
document.cookie = "visited=true; expires=" + expire;
$.colorbox({width:"620px", height:"450px", inline:true, href:"#subscribe"});
$("#cboxClose").click(function()
{
document.getElementById('playaudio').play();
});
}
});</script>
关于jquery - 关闭colorbox弹出窗口后如何编写jQuery播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23005788/