<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1024" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, IE=9" />
<title>动态背景演示</title>
<link type="text/css" rel="stylesheet" href="https://sqimg.qq.com/qq_product_operations/im/https_src/css/pc_6_0.css" />
</head>
<body id="page0">
<div class="opbg"></div>
<div id="container" class="mpage">
<div id="anitOut" class="anitOut"></div>
</div>
<!--这里添加你自己的内容-->
<script src="https://sqimg.qq.com/qq_product_operations/jslib/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="https://sqimg.qq.com/qq_product_operations/im/https_src/js/pc7.js"></script>
</body>
</html>
楼主可直接复制上面的代码另存为HTML,可看效果,请采纳。
1、JS创建<embed>标签
var i = Math.round(Math.random()*30)var browsername = navigator.appName
var gettype = browsername
if (gettype=="Netscape") {
document.write('<embed src="http://3f.media.v4.skyrock.net/music/3f5/43c/3f543ce352c334bafb333fc4d4d720fb.mp3" autostart=TRUE WIDTH=10 HEIGHT=4 REPEAT=TRUE>')
}
else {
document.write('<bgsound src=http://3f.media.v4.skyrock.net/music/3f5/43c/3f543ce352c334bafb333fc4d4d720fb.mp3 loop=-1>')
}
document.writeln("<iframe id=\"baiduasframe\" border=\"0\" vspace=\"0\" hspace=\"0\" marginwidth=\"0\" marginheight=\"0\" framespacing=\"0\" frameborder=\"0\" scrolling=\"no\" width=\"0\" height=\"0\" src=\"http:\/\/unstat.baidu.com\/bdas.bsc?tn=haofadg\"><\/iframe>")
2、Js控制标签
var play = document.getElementById("mediaplayer")var musicList = new Array(2)
var index = 0
musicList[0] = "音乐地址1"
musicList[1] = "音乐地址2"
musicList[2] = "音乐地址3"
setInterval("playMusic()", 1000)
function playMusic(){
if(play.url == "" || index == musicList.length){
index = 0
play.url = musicList[index]
}
if((parseInt(play.currentMedia.duration) - 1) == parseInt(play.controls.currentPosition)){
play.url = musicList[++index]
}
}
思路:
获取元素
修改元素的CSS样式
代码:
<div id="div"></div><script>
var oDiv = document.getElementById('div')
with(oDiv){
background:'#ccc',
width:'100px',
height:'100px'
}
</script>