JavaScript代码问题
<!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>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 跟随鼠标运动的蛇形文字 </title>
<script type= "text/javascript ">
<!--
var theX=0; theY=0;
var space1 = 15; space2 = 15;
var message = "Welcome To Our Station!! ";
messageArray = message.split( " ");
var xpos = new Array();
for(var i=0;i <=message.length-1;i++)
{
xpos[i] = -50;
}
var ypos = new Array();
for(var i=0;i <=message.length-1;i++)
{
ypos[i] = -50;
}
function getMousePos(e)
{
theX = document.body.scrollLeft + event.clientX;
theY = document.body.scrollTop + event.clientY;
}
function makesnake()
{
for(var i=messageArray.length-1;i> =1;i--)
{
xpos[i] = xpos[i-1] + space2;
ypos[i] = ypos[i-1];
}
xpos[0] = theX + space1;
ypos[0] = theY;
for(var i=0;i <messageArray.length-1;i++)
{
document.getElementById( "div " + i).style.left = xpos[i];
document.getElementById( "div " + i).style.top = ypos[i];
}
setTimeout( "makesnake() ",30);
}
for(var i=0;i <=messageArray.length-1;i++)
{
document.write( " <div id = 'div " + i + " '> ");
document.write(messageArray[i]);
document.write( " </div> ");
}
document.onmousemove = getMousePos;
//-->
</script>
</head>
<body onload= "makesnake(); ">
</body>
</html>
帮我看下为什么不能实现蛇形文字特效
------解决方案--------------------把我这个放到一起,就能出现你要的效果