跟随鼠标的文字

 

点击这里看效果


在 <head> 与 </head> 之间加入:

<STYLE>
.spanstyle {color="#808080";
FONT-FAMILY: "Courier New";
FONT-SIZE: 9pt;
POSITION: absolute;
TOP: -50px;
VISIBILITY: visible}
.gray1 {font-family: "宋体", "simsun";
font-size: 12.6px;color: #C80000}
</STYLE>

<SCRIPT>
var x,y
var step=10
var flag=0


<!--/*在这里改变文字*/
var message=" Welcome to ::5d city::::::::::"


message=message.split("")
var xpos=new Array()
for (i=0;i<=message.length-1;i++) {
xpos[i]=-50
}

var ypos=new Array()
for (i=0;i<=message.length-1;i++) {
ypos[i]=-50
}

function handlerMM(e){
x = (document.layers) ? e.pageX :
document.body.scrollLeft+event.clientX
y = (document.layers) ? e.pageY :
document.body.scrollTop+event.clientY
flag=1
}

function makesnake() {
if (flag==1 && document.all) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y

for (i=0; i<message.length-1; i++) {
var thisspan = eval("span"+(i)+".style")
thisspan.posLeft=xpos[i]
thisspan.posTop=ypos[i]
}
}

else if (flag==1 && document.layers) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y

for (i=0; i<message.length-1; i++) {
var thisspan = eval("document.span"+i)
thisspan.left=xpos[i]
thisspan.top=ypos[i]
}
}
var timer=setTimeout("makesnake()",30)
}

function MM_showHideLayers() {
var i, visStr, args, theObj;
args = MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) { (objNS,objIE,visStr)
visStr = args[i+2];
if (navigator.appName == 'Netscape' && document.layers != null) {
theObj = eval(args[i]);
if (theObj) theObj.visibility = visStr;
} else if (document.all != null) {
if (visStr == 'show') visStr = 'visible';
if (visStr == 'hide') visStr = 'hidden';
theObj = eval(args[i+1]);
if (theObj) theObj.style.visibility = visStr;
} }
}

function MM_swapImgRestore() {
if (document.MM_swapImgData != null)
for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
document.MM_swapImgData[i].src =
document.MM_swapImgData[i+1];
}

function MM_preloadImages() {
if (document.images) {
var imgFiles = MM_preloadImages.arguments;
if (document.preloadArray==null) document.preloadArray = new Array();
var i = document.preloadArray.length;
with (document) for (var j=0; j<imgFiles.length; j++)
if (imgFiles[j].charAt(0)!="#"){
preloadArray[i] = new Image;
preloadArray[i++].src = imgFiles[j];
} }
}

function MM_swapImage() {
var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
(objStr.indexOf('document.all[') ==0 && document.all ==null))
objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
obj = eval(objStr);
if (obj != null) {
swapArray[j++] = obj;
swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
obj.src = MM_swapImage.arguments[i+2];
} }
document.MM_swapImgData = swapArray;
}
</SCRIPT>


<script language=JavaScript1.2>
function high(which){
theobject=which
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which){
clearInterval(highlighting)
which.filters.alpha.opacity=25
}
function highlightit(that){
if (that.filters.alpha.opacity<100)
that.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
</script>

在 <body> 与 </body> 之间加入:

<SCRIPT>
for (i=0;i<=message.length-1;i++) {
document.write("<span id='span"+i+"' class='spanstyle'>")
document.write(message[i])
document.write("</span>")
}

if (document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
</SCRIPT>

把 <body> 改成:

<BODY onload=makesnake(); style="OVERFLOW-X: hidden;
OVERFLOW-Y: scroll; " bgColor=#000000>