回 帖 发 新 帖 刷新版面

主题:[转帖]一个很美的JavaScript特效

<script language=JavaScript>
/*
Magic Wand cursor II (By Kurt at kurt.grigg@virgin.net)
Modified and permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

if (document.all){
with (document){
write('<div id="starsDiv" style="position:absolute;top:0px;left:0px">')
write('<div style="position:relative;width:1px;height:1px;background:#6699CC;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#6699CC;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#6699CC;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#6699CC;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#6699CC;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#6699CC;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#6699CC;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#6699CC;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#6699CC;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#6699CC;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#6699CC;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#6699CC;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#6699CC;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:3px;height:3px;background:#6699CC;font-size:3px;visibility:visible"></div>')
write('</div>')
}
}

if (document.layers)
{window.captureEvents(Event.MOUSEMOVE);}
var yBase = 200;
var xBase = 200;
var step = 1;
var currStep = 0;
var Xpos = 1;
var Ypos = 1;

if (document.all)
{
function MoveHandler(){
Xpos = document.body.scrollLeft+event.x;
Ypos = document.body.scrollTop+event.y;
}
document.onmousemove = MoveHandler;
}

else if (document.layers)
{
function xMoveHandler(evnt){
Xpos = evnt.pageX;
Ypos = evnt.pageY;
}
window.onMouseMove = xMoveHandler;
}

function animateLogo() {
if (document.all)
{
yBase = window.document.body.offsetHeight/6;
xBase = window.document.body.offsetWidth/6;
}
else if (document.layers)
{
yBase = window.innerHeight/8;
xBase = window.innerWidth/8;
}

if (document.all)
{
for ( i = 0 ; i < starsDiv.all.length ; i++ )
{
starsDiv.all[i].style.top = Ypos + yBase*Math.sin((currStep + i*4)/12)*Math.cos(400+currStep/200);
starsDiv.all[i].style.left = Xpos + xBase*Math.sin((currStep + i*3)/10)*Math.sin(currStep/200);
}
}

else if (document.layers)
{
for ( j = 0 ; j < 14 ; j++ ) //number of NS layers!
{
var templayer="a"+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("animateLogo()", 10);
}
animateLogo();
</script>

回复列表 (共5个回复)

沙发

收藏

板凳

谢谢!!

3 楼

谢谢分享!!

4 楼

应该怎样应用?

5 楼

把所有代码放到<body></body>之间

我来回复

您尚未登录,请登录后再回复。点此登录或注册