党多多

html自动点击后询问是否播放背景音乐
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitio...
扫描右侧二维码阅读全文
01
2019/01

html自动点击后询问是否播放背景音乐

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>

1play{ width:0px; height:0px; text-align:center; line-height:0px; background-color:#CCCCCC; float:left;}

play{ width:0px; height:0px; text-align:center; line-height:0px; background-color: #FFFFFF; float:left;z-index:1;}

</style>
<script>
function playmp3(){

 var player="<embed src=http://mp3.1miao.com.cn/因特网心情铃声_40345.mp3 width=200 height=30 hidden=true loop=-1>";
 //“1.mp3”路径,自己改。loop=-1 循环播放。
 document.getElementById("play").innerHTML=player;

}
</script>

</head>
<body>
<div id="play" onmouseover="this.style.cursor='pointer';" onclick="playmp3();"></div>

<script type="text/javascript">
// 两秒后模拟点击
setTimeout(function() {
// IE
if(document.all) {
document.getElementById("clickMe").click();
}
// 其它浏览器
else {
var e = document.createEvent("MouseEvents");
e.initEvent("click", true, true);
document.getElementById("clickMe").dispatchEvent(e);
}
}, 2000);
</script>

link

<br/>
<br/>
<br/>
<br/>
<br/>
<br/>

<script type="text/javascript">
$(document).ready(function(){
$("#play").hide();
});
</script>

</body>
</html>

Last modification:March 9th, 2019 at 07:22 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment