萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 安卓開發 >> html5雪花的代碼

html5雪花的代碼

下面我們給大家介紹一下html5雪花的代碼吧!希望大家可以在這裡學習!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

<html xmlns="

<head>

<title>圍繞鼠標不停運動的雪花</title>

<meta http-equiv="content-type" content="text/html;charset=gb2312">

<!--把下面代碼加到<head>與</head>之間-->

<script language="javascript">

<!-- Begin

var images='/images/20100820/xuehua01.gif';

var amount=7;

var cnter=70;

var step;

var currStep = 0;

var Xpos = 0;

var Ypos = 0;

if (document.all)

{

document.write('<div id="ieDiv" style="position:absolute;top:0px;left:0px">')

document.write('<div id="c" style="position:relative">');

for (n=0; n < amount; n++)

document.write('<img src="'+images+'" style="position:absolute;top:0px;left:0px">')

document.write('</div>')

document.write('</div>')

function MsieMouseFollow(){

Xpos = document.body.scrollLeft+event.x-5;

Ypos = document.body.scrollTop+event.y-5;

}

document.onmousemove = MsieMouseFollow;

}

else if (document.layers)

{

window.captureEvents(Event.MOUSEMOVE);

for (ns=0; ns < amount; ns++)

document.write("<layer name='n"+ns+"' left='0' top='0'><img src='"+images+"'></layer>");

function NsMouseFollow(evnt){

Xpos = evnt.pageX-5;

Ypos = evnt.pageY-5;

}

window.onMouseMove = NsMouseFollow;

}

function Swirl(){

if (currStep<0.0550)

step=0.001;

if (document.all)

{

for (i=0;i<ieDiv.all.c.all.length;i++)

{

ieDiv.all.c.all[i].style.top = Ypos+cnter*Math.cos((currStep+i*4.5)/5)*Math.sin((currStep)*150);

ieDiv.all.c.all[i].style.left = Xpos+cnter*Math.sin((currStep+i*4.5)/5)*Math.sin((currStep)*150);

}

}

else if (document.layers)

{

for ( i = 0 ; i < ns ; i++ )

{

var temp="n"+i

document.layers[temp].top = Ypos+cnter*Math.cos((currStep+i*4.5)/5)*Math.sin((currStep)*150);

document.layers[temp].left =Xpos+cnter*Math.sin((currStep+i*4.5)/5)*Math.sin((currStep)*150);

}

}

currStep += step;

setTimeout("Swirl()", 10);

if (currStep>0.0540)

{

step+=0.002;

if (document.layers)

{

for ( i = 0 ; i < ns ; i++ )

{

var temp="n"+i

document.layers[temp].top =Ypos+cnter*Math.cos((currStep+i*4.5)/5)

document.layers[temp].left=Xpos+cnter*Math.sin((currStep+i*4.5)/5)

}

}

else if (document.all)

{

for (i=0;i<ieDiv.all.c.all.length;i++)

{

ieDiv.all.c.all[i].style.top=Ypos+cnter*Math.cos((currStep+i*4.5)/5)

ieDiv.all.c.all[i].style.left=Xpos+cnter*Math.sin((currStep+i*4.5)/5)

}

}

}

if (step > 0.5)

{

step=0.5;

cnter-=8;

}

if (document.layers)

_y=-window.innerWidth;

else if (document.all)

_y=-document.body.clientWidth;

if (cnter <= _y)

{

currStep=0;

step=0.001;

cnter=70;

}

}

Swirl();

// End -->

</script>

</head>

<!--把<body>改為-->

<body bgcolor="#000000">

</body>

</html>

<p align="center"><font color=skyblue></font></p>

以上就是我們給大家介紹的html5雪花的代碼了。希望大家可以繼續關注我們的網站!

copyright © 萬盛學電腦網 all rights reserved