⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8-4.html

📁 JavaScript经典实例教程代码
💻 HTML
字号:
<html>
<head>
<title>rotateLayer</title>
<META http-equiv="content-type" CONTENT="text/html;charset=gb2312">
<META NAME="Author" CONTENT="CZH;czh44@sohu.com">
</head>
<script language="JavaScript">
/*--------------------------------\
|  Authored by CZH;czh44@sohu.com |
\--------------------------------*/
var yBase = 200;
var xBase = 200;
var step = 1;
var currStep = 0;
var Xpos = 1;
var Ypos = 1;
var tempLayer;
ifNN4 = (navigator.appName=="Netscape"&&parseInt(navigator.appVersion)==4);
ifNN6 = (navigator.appName=="Netscape"&&parseInt(navigator.appVersion)==5);
if(ifNN4)
{
	with(document)
	{
	write('<layer name=lay0 bgcolor=#0000000 width="1px" height="1px"></layer>')
	write('<layer name=lay1 bgcolor=#0000000 width="1px" height="1px"></layer>')
	write('<layer name=lay2 bgcolor=#0000000 width="1px" height="1px"></layer>')
	write('<layer name=lay3 bgcolor=#0000000 width="1px" height="1px"></layer>')
	write('<layer name=lay4 bgcolor=#0000000 width="2px" height="2px"></layer>')
	write('<layer name=lay5 bgcolor=#0000000 width="2px" height="2px"></layer>')
	write('<layer name=lay6 bgcolor=#0000000 width="2px" height="2px"></layer>')
	write('<layer name=lay7 bgcolor=#0000000 width="2px" height="2px"></layer>')
	write('<layer name=lay8 bgcolor=#0000000 width="3px" height="2px"></layer>')
	write('<layer name=lay9 bgcolor=#0000000 width="3px" height="2px"></layer>')
	write('<layer name=lay10 bgcolor=#0000000 width="3px" height="2px"></layer>')
	write('<layer name=lay11 bgcolor=#0000000 width="3px" height="3px"></layer>')
	write('<layer name=lay12 bgcolor=#0000000 width="3px" height="3px"></layer>')
	write('<layer name=lay13 bgcolor=#0000000 width="3px" height="3px"></layer>')
	}
 	function getMousePos1(eventObject)
	{
	Xpos = eventObject.pageX;
	Ypos = eventObject.pageY;
	}
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = getMousePos1;
}
else
{//在NN6浏览器及IE浏览器中定义层
	with (document)
	{
	write('<div id=lay0 style="position:absolute;width:1px;height:1px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay1 style="position:absolute;width:1px;height:1px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay2 style="position:absolute;width:1px;height:1px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay3 style="position:absolute;width:1px;height:1px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay4 style="position:absolute;width:2px;height:2px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay5 style="position:absolute;width:2px;height:2px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay6 style="position:absolute;width:2px;height:2px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay7 style="position:absolute;width:2px;height:2px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay8 style="position:absolute;width:3px;height:2px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay9 style="position:absolute;width:3px;height:2px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay10 style="position:absolute;width:3px;height:2px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay11 style="position:absolute;width:3px;height:3px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay12 style="position:absolute;width:3px;height:3px;background:#000000;visibility:visible;font-size=1px"></div>')
	write('<div id=lay13 style="position:absolute;width:3px;height:3px;background:#000000;visibility:visible;font-size=1px"></div>')
	}
	function getMousePos2(eventObject)
	{
		if(ifNN6)
		{
		Xpos = eventObject.pageX;
	    Ypos = eventObject.pageY;
		}
		else
		{   
	    Xpos = document.body.scrollLeft+event.x;
	    Ypos = document.body.scrollTop+event.y;
	    }
	}
	document.onmousemove = getMousePos2;
}
function makeAnimate()
{
	if(ifNN4)
	{
	yBase = window.innerHeight/8;
	xBase = window.innerWidth/8;
		for ( j = 0 ; j < 14 ; j++ ) 
		{
	  	tempLayer="lay"+j;
		document.layers[tempLayer].top = Ypos + yBase*Math.sin((currStep + j*4)/12)*Math.cos(400+currStep/200);
		document.layers[tempLayer].left = Xpos + xBase*Math.sin((currStep + j*3)/10)*Math.sin(currStep/200);
		}
	currStep += step;
	setTimeout("makeAnimate()", 10);
	}
	else
	{
		if(ifNN6)
		{
		yBase = window.innerHeight/8;
		xBase = window.innerWidth/8;
		}
		else
		{ 
		yBase = window.document.body.clientHeight/8;
		xBase = window.document.body.clientWidth/8;
		}
		for ( i = 0 ; i < 14; i++ )
		{
		tempLayer="lay"+i;
		document.getElementById(tempLayer).style.top = Ypos + yBase*Math.sin((currStep + i*4)/12)*Math.cos(400+currStep/200);
		document.getElementById(tempLayer).style.left = Xpos + xBase*Math.sin((currStep + i*3)/10)*Math.sin(currStep/200);
		}
	currStep += step;
	setTimeout("makeAnimate()", 10);
	}
}
</script>
<body onload="makeAnimate()">
</body>
<html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -