พบกับบทความเกี่ยวกับคอมพิวเตอร์และ programming ได้ที่ http://articles.modoeye.com
Flash help / อยากให้เม้าส์มีตัวอักษร
guest
guest
Fri 9 Sep 2005 14:01:09

อยากให้เม้าส์มีตัวอักษรเวลาอยู่ในเว็บน่ะครับทำงัย ตัวอย่างครับhttp://computer.act.ac.th/comservice/topweb_download1.htm

Administrator
Fri 9 Sep 2005 15:41:16

โค๊ดนี้ต้องขอโทษด้วยครับไม่ได้เขียนเองครับเพียงแต่หาข้อมูลมาให้ครับ เท่าที่ทดลองจะใช้ได้เฉพาะ IE5+ กับ Opera7 เท่านั้นนะครับ Mozilla base เท่าที่ลองไม่ได้ผลครับ

ส่วนแรกเป็นของ stylesheet ครับ สามารถแก้ไขได้ตรง font-family, font-size,color ครับ

<style type="text/css">
<!--
.mouse
{
position:absolute;
visibility:visible;
top:-50px;
font-size:8px;
font-family:arial;
color:black;
}
body
{
width:100%;
overflow-x:hidden;
overflow-y:scroll;
}
-->
</style>

ส่วนที่ 2 เป็นส่วนของ javascript ครับโดยส่วนที่แก้ไขได้คือ step และ text ครับ หรือถ้าเข้าใจระบบทั้งหมดแล้วลอง implement เป็นแบบของตัวเองดูก๋ได้ครับ

<script language="javascript">
var x,y
var step=20
var doit=0
var text="Animation "
text=text.split("")

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

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

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

function trail() {
 if (doit==1 && document.all) {
     for (i=text.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<text.length-1; i++) {
      var place = eval("span"+(i)+".style")
      place.posLeft=xpos[i]
   place.posTop=ypos[i]
     }
 }
 
 else if (doit==1 && document.layers) {
     for (i=text.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<text.length-1; i++) {
      var place = eval("document.span"+i)
      place.left=xpos[i]
   place.top=ypos[i]
     }
 }
  var timer=setTimeout("trail()",30)
}

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

if (document.layers){
 document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = anddo;

</script>

นำทั้งสองส่วนนี้ไปใส่ไว้รหว่าง head tag ครับ

ที่เหลือก็เพียงเรียกใช้งาน script เท่านั้นครับโดยอาจจะเรียกเมื่อมีการ load เอกสารก็ได้ครับ เช่น <body onLoad="trail()">

guest
guest
Fri 9 Sep 2005 16:29:25

เยี่ยมมากเลยครับ เก่งจริง ๆ เว็บมาสเตอร์คนนี้ ...ขอให้มีคนเข้ามาเยอะ ๆ นะครับ

Whaleshark
Whaleshark
Thu 14 Sep 2006 13:50:15
เวปนี้แจ่มมากครับ จะช่วยโปรโมทให้นะครับ ^_^
Whaleshark
Whaleshark
Thu 14 Sep 2006 13:51:11
เวปนี้แจ่มมากครับ จะช่วยโปรโมทให้นะครับ ^_^
Reply
Name:
E-mail:
Home | Services | Forum | Classified | Directories | Support | Contact
ATOM feed RSS 0.9 feed RSS 1.0 feed RSS 2.0 feed
Copyright © 2005 - 2007 Modoeye.com, All Rights Reserved.
Disclaimer | Privacy policy | Term of Use | Term of Services
Valid XHTML Valid CSS! PHP: Hypertext Preprocessor MySQL database Apache Powered! FreeBSD Power to serve
Modoeye Sitemap Client login