月儿弯弯照九州 古风:怎么弄有跟着鼠标跑的字 ,,../ko
怎么弄有跟着鼠标跑的字?
网页做好了还想弄这个 怎么弄?
问题补充:回答者:shenjieokok - 助理 二级 谢谢你啊 可我还是不懂怎么加啊怎么加呢 我怎么把代码复制上去就是看见个隐藏域 看不到字啊 有没有更简单的方法 能帮我加一下让我粘贴上去就可以用吗?
回答者:shenjieokok - 助理 二级的回答 大家庭帮帮再详细点啊
将以下代码加入到HEML之中:
跟随鼠标的文字[修改显示的文字及颜色代码即可][共1步]
====1、将以下代码加入HTML的<body></body>之间
<style type="text/css">
.spanstyle {
position:absolute;
visibility:visible;
top:-50px;
font-size:9pt;
color: #000000;
font-weight:bold;
}</style>
<script>
var x,y
var step=20
var flag=0
var message="主页特效制作百宝箱。"
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)}
</script>
<body onLoad="makesnake()" >
<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>
< html >
< head >
< title >Mouse trace< /title >
< script LANGUAGE="JavaScript" >
< !--
function Layerfx(yyleft,yytop,yyfnx,yyfny,yydiv,
yybilder,yyloop,yyto,yycnt,yystep)
{ // 设置重绘层的Layerfx函数
if ((document.layers)||(document.all)){
with (Math) {yynextx= eval(yyfnx)}
with (Math) {yynexty= eval(yyfny)}
yycnt=(yyloop && yycnt >
=yystep*yybilder)?0:yycnt+yystep;
if (document.layers){//针对NC浏览器定义层的坐标
eval(yydiv+".top="+(yynexty+yytop))
eval(yydiv+".left="+(yynextx+yyleft))
}
if (document.all){//针对IE浏览器定义层的坐标
eval("yydiv=yydiv.replace(/.layers/gi, '.all')");
eval(yydiv+".style.pixelTop="+(yynexty+yytop));
eval(yydiv+".style.pixelLeft="+(yynextx+yyleft));
}
argStr='Layerfx('+yyleft+','+yytop+',"'+yyfnx+'",
"'+yyfny+'","'+yydiv+'",'+yybilder+','+yyloop+',
'+yyto+','+yycnt+','+yystep+')';
if (yycnt< =yystep*yybilder)
{
eval(yydiv+".yyto=setTimeout(argStr,yyto)");}
//加入时间控制
}
}
function Mousetrace(evnt)
{
if (yyns4) //针对NC浏览器,根据鼠标位置,
获得层新的X,Y坐标
{if (evnt.pageX) {ml=evnt.pageX; mt=evnt.pageY;} }
else{ //针对IE浏览器,根据鼠标位置,
获得层新的X,Y坐标
ml=(event.clientX + document.body.scrollLeft);
mt=(event.clientY + document.body.scrollTop);
}
if (tracescript)eval(tracescript)
}
//-- >
< /script >
< body bgcolor="#FFFFFF" >
< div align="center" >< center >
< table border="0" cellpadding="0"
cellspacing="0" width="100%" >
< /table >
//作一个全屏幕的表格作为触发ONMOUSEOVER的对象
< /center >< /div >
< div align="center" >< /div >
< div id="yyd0"
//画出6个3X3的不同颜色的层
,就是6个彩色小点
s="position:absolute; left:10px;
top:50px; width:3px; height:3px; z-index:1;
background-color: #33bbaa;
clip: rect(0 3 3 0)" >< /div >< div
id="yyd1"
s="position:absolute; left:20px; top:50px;
width:3px; height:3px; z-index:1; background-color:
#ff2022; clip: rect(0 3 3 0)" >< /div >< div
id="yyd2"
s="position:absolute; left:30px; top:50px;
width:3px; height:3px; z-index:1; background-color:
#cc3399; clip: rect(0 3 3 0)" >< /div >< div
id="yyd3"
s="position:absolute; left:40px; top:50px;
width:3px; height:3px; z-index:1; background-color:
#ffff00; clip: rect(0 3 3 0)" >< /div >< div
id="yyd4"
s="position:absolute; left:50px; top:50px;
width:3px; height:3px; z-index:1; background-color:
#3366cc; clip: rect(0 3 3 0)" >< /div >< div
id="yyd5"
s="position:absolute; left:60px; top:50px;
width:3px; height:3px; z-index:1; background-color:
#5add55; clip: rect(0 3 3 0)" >< /div >
< script >
var yyns4=window.Event?true:false; var mt = 0; var ml = 0;
document.onmousemove = Mousetrace;
tracescript = '';
if (yyns4){ document.captureEvents(Event.MOUSEMOVE);
//获得鼠标移动事件
Mousetrace('',',document.Mousetrace1')}
Layerfx(0,0,'ml+cos((15*sin(yycnt/24.
247212049632708))+0)*150*(sin(10+yycnt/20)+0.2)*
cos(yycnt/20)',
'mt+sin((15*sin(yycnt/36.13878534416527))+0)*
150*(sin(10+yycnt/20)+0.2)*cos(yycnt/20)',
'document.layers[\'yyd0\']',2000,true,80,0,1);
Layerfx(0,0,'ml+cos((15*sin(yycnt/
14.259312736364942))+30)*150*(sin(10+yycnt/20)+0.2)*
cos(yycnt/20)',
'mt+sin((15*sin(yycnt/33.055333176403245))+30)
*150*(sin(10+yycnt/20)+0.2)*cos(yycnt/20)',
'document.layers[\'yyd1\']',2000,true,80,0,1);
Layerfx(0,0,'ml+cos((15*sin(yycnt/
21.77522790563416))+60)*150*(sin(10+yycnt/20)+0.2)*
cos(yycnt/20)',
'mt+sin((15*sin(yycnt/38.00715313644094))+60)
*150*(sin(10+yycnt/20)+0.2)*cos(yycnt/20)','
document.layers[\'yyd2\']',2000,true,80,0,1);
Layerfx(0,0,'ml+cos((15*sin
(yycnt/16.94483476520931))+90)*150*
(sin(10+yycnt/20)+0.2)*cos(yycnt/20)',
'mt+sin((15*sin(yycnt/28.81649093984075))+90)
*150*(sin(10+yycnt/20)+0.2)*cos(yycnt/20)','
document.layers[\'yyd3\']',2000,true,80,0,1);
Layerfx(0,0,'ml+cos((15*sin
(yycnt/13.322848843155297))+120)*150
*(sin(10+yycnt/20)+0.2)*cos(yycnt/20)',
'mt+sin((15*sin(yycnt/13.743055559979211))
+120)*150*(sin(10+yycnt/20)+0.2)*cos(yycnt/20)','
document.layers[\'yyd4\']',2000,true,80,0,1);
Layerfx(0,0,'ml+cos((15*sin
(yycnt/31.727090784502128))+150)*150*
(sin(10+yycnt/20)+0.2)*cos(yycnt/20)',
'mt+sin((15*sin(yycnt/12.66553778007537))
+150)*150*(sin(10+yycnt/20)+0.2)*cos(yycnt/20)'
,'document.layers[\'yyd5\']',2000,true,80,0,1);
//根据层新的坐标重新画层
< /script >
< /body >
< html >