Javascript Mouse Event Handler Example

CK CK 3788 
Created at  
404 0 0
Simple, but pretty good reference for studying purpose.

<!--------------------
  shivascm@hotmail.com
 -------------------->

<html>
<head>

<style>
.spanstyle {
    position:absolute;
    visibility:visible;
    top:-50px;
    font-size:10pt;
    font-family:Verdana;
      font-weight:bold;
    color:black;
}
</style>

<script language="Javascript">
var x,y
var step=20
var flag=0

var message="MOUSE TEXT!!!" //Your text goes here
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 flow() {
    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("flow()",30)
}

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>

</head>
<body onLoad="flow()" style="width:100%;overflow-x:hidden;overflow-y:scroll">
<form name="frm">
</form>
</body>
</html>

Tags Checkbox HTML Javascript Javscript Mouse Event Mouse Mouse Event Facebook X
Comments 0
Similar posts
  1. Getting WebSearchers On Your Site
    374
  2. Select And Deselect All Checkboxes By Javascript
    632
  3. Hiding HTML on the browser
    462
  4. How to get date time in Javascript ?
    500
  5. Javascript based Alarm Clock
    669
  6. Javascript implemented Calendar
    423
  7. Basic Date Display
    513
  8. Address Book
    577
  9. Displays the number of pages that the users browser has displayed in its session
    667
  10. Greeting For The Time Of Day
    393
  11. Access Granted
    587
  12. Cookie enabled browser checking in Javascript
    342
  13. Cookie Redirect
    497
  14. New content notifier in Javascript
    599
  15. Let popup once for event dialog or something like that in Javascript
    426
  16. Save And Restore Form Cookies in Javascript
    335
  17. How to record visitor's name by Cookie
    412
  18. Javascript & Cookie based Visitor Application
    437
  19. Cross Browser Event Management Functions Using JavaScript
    611
  20. Confirm The Link Clicked
    631
  21. Enlarge Image
    514
  22. Dual Scroller
    333
  23. Cursor Changer
    384
  24. Color Table
    366
  25. Printing A Page
    380
  26. Example Of Creating Objects
    404
  27. Linking Drop Downs
    578
  28. Roman Numerals From Integers
    513
  29. Get A Print Dialog Box By Clicking A Button
    820
  30. Keyboard event detection (Key Tracker)
    1,090
  1. Document Fader
    346
  2. Book Mark This Site
    405
  3. Icon Coupled Url
    427
  4. Button That Will Close The Browser Window
    350
  5. Button That Will Show The Page's Source
    388
  6. Add A Scrolling Status Bar Text To Your Site
    409
  7. Add This Page To Favorites
    402
  8. Code To Clear Browser History
    375
  9. Remove the spaces before begin and after end of text
    338
  10. How To Close A Pop-up Window ?
    443
  11. Pop Up Window On Top
    518
  12. How to display message on browser status bar ?
    476
  13. New Window
    606
  14. Firefox Web Tweaking
    376
  15. Send An Email Using A Bean
    1,015
  16. jQuery and Function Chaining
    539
  17. IsIn For Arrays
    570
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    42
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    36
  3. How do I create animated background for Google Meet?
    21,019
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    251
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    515
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    288
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    232
  16. TPU & GPU Cluster Management Tools
    245
  17. The Concept of Scaffolding in AI Agents
    234
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    259
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    222
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    221
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    196
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    219
  30. Understanding Data Lineage
    263