test

<!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>
<title> 预览窗口</title>
</head>
<body>

<div id="example">
<h3 id="example_title">


<div id="example_main">
<textarea cols="70" rows="20" id="code">
<!--************************************* 开始*************************************-->

<html>
<head>
<title></title>
</head>
<body>
<script>
var FireColor = ["red","blue","yellow","orange","pink"];
var FireStyle = ["¤","","","",""];
var StarStyle = ["","","","",""];
function xo() { this.x=0;this.y=0;this.power=Math.floor(Math.random()*arguments[0]+arguments[1]);
}
function star(c)
{
   
var handle=this;
    xo.call(
this,100,0);
   
this.star=StarStyle[Math.floor(Math.random()*4)];
   
this.angle=2*Math.PI*Math.random()+1;
   
this.o=document.createElement("span");
    document.body.appendChild(
this.o);
   
this.o.innerHTML=this.star;
   
this.style=this.o.style;
   
this.color=c;
   
this.exist=false;
   
with(this.style)
    {
        visibility
="hidden";
        position
="absolute";
        color
=this.color;
    }
   
this.move=function()
    {
       
if(this.y<this.power)
        {
           
this.y+=2;
           
with(this.style)
            {
                top
=this.y;
                left
=this.x+this.y*Math.sin(this.angle);
            }
        }
else
        {
           
this.clear();
        }
    }
   
this.burn=function(x,y)
    {
       
this.style.left=this.x=x;
       
this.style.top=this.y=y;
    }
   
this.shine=function(x,y)
    {
       
this.burn(x,y);
       
this.style.visibility="visible";
       
this.gogo=setInterval(function(){handle.move()},17);
    }
   
this.clear=function()
    {
       
this.o.parentNode.removeChild(this.o);
        clearInterval(
this.gogo);
    }
}
function Firework()
{
   
var handle=this;
    xo.call(
this,10,25);
   
this.color=FireColor[Math.floor(Math.random()*4)];
   
this.shape=FireStyle[Math.floor(Math.random()*4)];
   
this.starnum=Math.floor(Math.random()*7)+5;
   
this.star = new Array();
   
this.exist=true;
   
for(var i=0;i<this.starnum;i++)
    {
       
this.star[i]=new star(this.color);
    }
   
this.starnum=Math.floor(Math.random()*4)+4;
   
this.o = document.createElement("span");
    document.body.appendChild(
this.o);
   
this.o.innerHTML=this.shape;
   
this.style=this.o.style;
   
this.style.color=this.color;
   
this.style.position="absolute";
   
this.setX=function(x){this.style.left=x+"px";this.x=x;}
   
this.setY=function(y){this.style.top=y+"px";this.y=y;}
   
this.move=function()
    {
       
this.y -=this.power/3;   
        if(this.y>this.power)
           
this.style.top=this.y + "px";
       
else
        {
           
if(this.exist)this.clear();
        }
    }
   
this.fire=function()
    {
       
this.gogo=setInterval(function(){handle.move()},17);
    };
   
this.clear=function()
    {
       
this.o.parentNode.removeChild(this.o);
        clearInterval(
this.gogo);
       
this.exist=false;
       
for(var i=0,j=this.star.length;i<j;i++)
        {
           
this.star[i].shine(this.x,this.y);
        }
    }
}
function FireScene(n)
{
   
this.num=n;
   
this.SceneWidth=document.body.clientWidth;
   
this.SceneHeight=document.body.clientHeight;
   
this.step=Math.floor(this.SceneWidth/this.num);
    this.firework=new Array();
   
for(var i=0;i<this.num;i++)
    {
       
this.firework[i]=new Firework();
       
this.firework[i].setX(this.step*i);
       
this.firework[i].setY(this.SceneHeight-50);
    }
   
this.fire=function()
    {
       
for(var i=0,j=this.firework.length;i<j;i++)
        {
           
this.firework[i].fire();
        }
    }
}
window.onload
=function()
{
    document.body.style.backgroundColor
= "Black";
   
new FireScene(8).fire()
    setInterval(
"new FireScene(8).fire()",2000);
}
</script>
</body>
</html>
<!--************************************* 结束*************************************-->
</textarea>

<script type="text/javascript">
function openWindow()
{
 newWindow = window.open('','newWindow'); 
 if (newWindow != null)
 {
  var windowHTML= document.getElementById('code').value;
  newWindow.document.write(windowHTML);
  newWindow.focus();
 }
}
</script>
</div>
</div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值