原理是这样的:1、小窗口跟踪鼠标:这是在document的onmouseover事件里通过screenX和screenY属性捕捉到鼠标的坐标,然后定位一个矩形区域(比如DIV)的style.top和style.left属性等于鼠标的坐标(也可以加上一些数值使矩形区域距离鼠标一些距离)2、通过setTimeout方法,使一个公共数值变量循环增加。算法可以是这样A=(A+1) Mod 10,在这个算法当中A将在0到9之间循环变动。而你可以定义一个字符串数组,根据变化的公共数值变量取得数组当中的指定元素,使矩形区域的innerText属性等于该元素的字符。我只会用VBScript,所以暂时帮不上你的忙。上面是原理,你可以查一查有关的书籍找到上面的命令和属性的含义,自己做出来是最好的。
<SCRIPT language="JavaScript1.2">
<!--
/*Cursor scroller script- By Dynamicdrive.com*/
//1) set message to display
var scroller_msg='Welcome to http://www.tastelife.net, 大量javascript代码!'
//2) set whether message should auto disappear after x seconds (0=perpetual).
//Note that double clicking page will also dismiss message
var dismissafter=0 //message 消失的时间(秒)var intMes=0 //显示的消息序号
mes=new Array("精彩文章1","精彩文章2","精彩文章3","精彩文章4","精彩文章5")
var rotateTime=3 //转换Message内容的时间(秒)var initialvisible=0 //是否显示messageif (document.all)
document.write('<marquee id="curscroll" SCROLLAMOUNT=9 SCROLLDELAY=120 style="position:absolute;width:150px;border:1px solid black;font-size:14px;background-color:white;visibility:hidden">'+mes[0]+'</marquee>')function followcursor(){
//move cursor function for IE if (initialvisible==0){
curscroll.style.visibility="visible"
initialvisible=1
} curscroll.style.left=document.body.scrollLeft+event.clientX+10
curscroll.style.top=document.body.scrollTop+event.clientY+10
//alert(curscroll.innerHTML);
}function dismissmessage(){
curscroll.style.visibility="hidden"
}function rotateMessage(){
++intMes;
if(intMes==mes.length){
intMes=0;
}
curscroll.innerHTML=mes[intMes];}if (document.all){
document.onmousemove=followcursor;
document.ondblclick=dismissmessage;
setInterval("rotateMessage()",rotateTime*1000);
if (dismissafter!=0)
setTimeout("dismissmessage()",dismissafter*1000)
}
//-->
</SCRIPT>