页面中飞行的烟花效果

<html>
<head>
</head>
<SCRIPT LANGUAGE="JavaScript1.2">
var intervals=2000
var sparksOn     = true;
var speed        = 40;
var power        = 3;
var documentWidth=documentHeight=randomx=randomy=leftcorner=topcorner=0
var ns=(document.layers);
var ie=(document.all);
var ns6=(document.getElementById&&!document.all);
var sparksAflyin = false;
var allDivs      = new Array(10);
var totalSparks  = 0;
function initAll(){
        if(!ns && !ie &&!ns6){
        sparksOn = false;
        return;
        }
setInterval("firework()",intervals)
if (ns)
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
        for(dNum=0; dNum<7; ++dNum){
                if(ie)
                        allDivs[dNum]=eval('document.all.sDiv'+dNum+'.style');
                else if (ns6)
                        allDivs[dNum]=document.getElementById('sDiv'+dNum).style;
                else
                        allDivs[dNum]=eval('document.layers["sDiv'+dNum+'"]');
        }
}

function firework(){
if (ie){
documentWidth=document.body.clientWidth
documentHeight=document.body.clientHeight
leftcorner=document.body.scrollLeft
topcorner=document.body.scrollTop
}
else if (ns||ns6){
documentWidth=window.innerWidth
documentHeight=window.innerHeight
leftcorner=pageXOffset
topcorner=pageYOffset
}
randomx=leftcorner+Math.floor(Math.random()*documentWidth)
randomy=topcorner+Math.floor(Math.random()*documentHeight)

        if(sparksOn){
                if(!sparksAflyin){
                        sparksAflyin=true;
                        totalSparks=0;
                        for(var spark=0;spark<=6;spark++){
                                dx=Math.round(Math.random()*50);
                                dy=Math.round(Math.random()*50);
                                moveTo(spark,randomx,randomy,dx,dy);
                        }
                }
        }

function moveTo(I,tempx,tempy,dx,dy){
        if(ie){
                if(tempy+80>(document.body.offsetHeight+document.body.scrollTop))
                        tempy=document.body.offsetHeight+document.body.scrollTop-80;
                if(tempx+80>(document.body.offsetWidth+document.body.scrollLeft))
                        tempx=document.body.offsetWidth+document.body.scrollLeft-80;
        }
        else if(ns6){
                if(tempy+80>(window.innerHeight+pageYOffset))
                        tempy=window.innerHeight+pageYOffset-80;
                if(tempx+80>(window.innerWidth+pageXOffset))
                        tempx=window.innerWidth+pageXOffset-80;
        }
        if(tempx>-50&&tempy>-50){
                tempx+=dx;tempy+=dy;
                allDivs[I].left=tempx;
                allDivs[I].top=tempy;
                dx-=power;dy-=power;
                setTimeout("moveTo("+I+","+tempx+","+tempy+","+dx+","+dy+")",speed)
        }
        else
                ++totalSparks
        if(totalSparks==7){
                sparksAflyin=false;
                totalSparks=0;
        }
}
window.onload=initAll
</script>
<style>
#sDiv0 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:Aqua; z-index:9;}
#sDiv1 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:red; z-index:10;}
#sDiv2 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:blue; z-index:11;}
#sDiv3 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:orange; z-index:12;}
#sDiv4 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:yellow; z-index:13;}
#sDiv5 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:lightgreen; z-index:14;}
#sDiv6 {position:absolute; height:1; width:1; font-family:arial black; font-size:15px; color:silver; z-index:15;}
</style>
<body bgcolor="#000000">
<a href="<#ZC_BLOG_HOST#>"><hr>

<div id="sDiv0">*</div>
<div id="sDiv1">*</div>
<div id="sDiv2">*</div>
<div id="sDiv3">*</div>
<div id="sDiv4">*</div>
<div id="sDiv5">*</div>
<div id="sDiv6">*</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值