我正在开发一个加载警报和 mp3 自动播放的页面。在 Firefox 中,警报会显示背景图像和声音,但在 Chrome 中,警报会在空网站上加载且没有声音,并且仅在单击“确定”后才显示背景图像。
CSS
body{padding:0;margin:0;font-family:arial,sans-serif;background:url(images/bgg.png)
HTML
<body >
....
....
<audio controls autoplay>
<source src="marimbaiph.mp3" type="audio/mpeg">
</audio></center><br>
<script type="text/javascript">
alert('Hello \nPlease Click "OK" to continue. ');
</script>
有没有办法在 Chrome 中显示背景图像并播放声音后弹出警报?
谢谢
最佳答案
在 $(document).ready
上插入您的操作
$(document).ready(function(){
alert('Hello \nPlease Click "OK" to continue. ');
});
关于Javascript 警报显示在背景图像之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29444247/