HTML鼠標跟蹤彩虹文字

一步驟 :
在<head></head>中加入如下代碼:<STYLE>.spanstyle {
COLOR: #0066ff; FONT-FAMILY: 宋體; FONT-SIZE: 12pt; FONT-WEIGHT: normal; POSITION: absolute; TOP: -50px; VISIBILITY: visible
}
</STYLE>

第二步驟 :
在<body>中加入如下代碼:<body onload="javascript:pageonload()" bgcolor="#000000">

第三步驟 :
在<body></body>中加入如下代碼:<script language=javascript>
var message="冰 海 家 園 網 頁 制 作 技 巧 資 源 網 站";
var x,y;
var step=12;
var flag=0;
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+10;
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];
thisspan.color=Math.random() * 255 * 255 * 255 + Math.random() * 255 * 255 + Math.random() * 255;
}
}
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];
thisspan.color=Math.random() * 255 * 255 * 255 + Math.random() * 255 * 255 + Math.random() * 255;
}
}
}
</script>
<script language=javascript>
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>
<script language=javascript>
function pageonload() {
makesnake();
window.setTimeout("pageonload();", 2);
}
</script>

 


riqi

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Year_Month(){
var now = new Date();
var yy = now.getYear();
var mm = now.getMonth()+1;
var cl = '<font color="#000000">';
return(cl +yy + '年' + mm + '月</font>');
}function Date_of_Today(){
var now = new Date();
var cl = '<font color="#000000"><b>';
if (now.getDay() == 0) cl = '<font color="#FF0000"><b>';
if (now.getDay() == 6) cl = '<font color="#008000"><b>';
return(cl +now.getDate() + '</font></b>');
}function Day_of_Today(){
var day = new Array();
day[0] = "星期日";
day[1] = "星期一";
day[2] = "星期二";
day[3] = "星期三";
day[4] = "星期四";
day[5] = "星期五";
day[6] = "星期六";
var now = new Date();
var cl = '<font color="#000000">';
if (now.getDay() == 0) cl = '<font color="#FF0000">';
if (now.getDay() == 6) cl = '<font color="#008000">';
return(cl +day[now.getDay()] + '</font>');
}function CurentTime(){
var now = new Date();
var hh = now.getHours();
var mm = now.getMinutes();
var ss = now.getTime() % 60000;
ss = (ss - (ss % 1000)) / 1000;
var clock = hh+':';
if (mm < 10) clock += '0';
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
return(clock);
}function refreshCalendarClock(){
document.all.calendarClock1.innerHTML = Year_Month();
document.all.calendarClock2.innerHTML = Date_of_Today();
document.all.calendarClock3.innerHTML = Day_of_Today();
document.all.calendarClock4.innerHTML = CurentTime();
}document.write('<table border="0" cellpadding="0" cellspacing="0" width="70" bgcolor="#C0C0C0" height="65">');
document.write('<tr><td valign="top" width="100%" height="100%">');
document.write('<table border="1" bordercolor="#993300" cellpadding="0" cellspacing="0" width="70" bgcolor="#FFFF99" height="65">');
document.write('<tr><td align="center" width="100%" height="100%" >');
document.write('<font id="calendarClock1" style="font-family:宋體;font-size:9pt;line-height:120%"> </font><br>');
document.write('<font id="calendarClock2" style="font-family:Arial;font-size:18pt;line-height:120%"> </font><br>');
document.write('<font id="calendarClock3" style="font-family:宋體;font-size:9pt;line-height:120%"> </font><br>');
document.write('<font id="calendarClock4" style="color:#000000;font-family:宋體;font-size:9pt;line-height:120%"><b> </b></font>');
document.write('</td></tr></table>');
document.write('</td></tr></table>');
refreshCalendarClock()
setInterval('refreshCalendarClock()',1000);
// End -->
</SCRIPT>


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章