Purchase Advertising On AWT
 Upload & Sell Your Software
 Upload & Sell Your eBook
 Enter The AWT Control Panel  Contact Applied Web Tools
 Sell Your eBook @ The Book Store  Password Troubles? Click Here!
Knowledge Center
Want to write for Applied Web Tools? Send your Writer's Query to
Editor@AppliedWebTools.net for details.
HTML
Reference
&
Tutorial
CSS
Reference
&
Tutorial
DOM
Reference
&
Tutorial
JavaScript
Reference
&
Tutorial
50+ Programming Examples
Use HTML, CSS, DOM & JavaScript Together
Misc. Essays & Documents
You'll Find Just About Anything In Here
50+ Web Page Constructions
Learn the Art of Using HTML, CSS, DOM & JavaScript Together
 Changing Background Colors
 Event Triggering With onLoad
 Disabling The Right Click
 DOM Driven Color Changing
 Switching Images
 innerHTML Attribute Access
 Change With innerHTML
 Changing Positions
 Change Position With onMouseMove
 Change Text Position
 Interactivity Skills
 Type-writing A Message
 Auto-changing Text Size
 Making Text Scroll
 Blinking Text
 Simple Form Authentication
 Change Background Color Of An INPUT
 Change Text Color Of An INPUT
 Change Background Image Of An INPUT
 Select All Checkboxes
 Select Color Of The Submit Button
 Change Text Color Of A Submit Button
 Insert Background Image To A Button
 Change Color Of Drop Down List
 Change Text Color Of A Drop Down List
 Change Color Of A TEXTAREA
 Change The Text Color Of A TEXTAREA
 Insert An Image Into A TEXTAREA
 Change The Size Of An Image
 Change The Source Of An Image
 Change The Position Of An Image
 Change The Background Image
 Moving Images Around The Page
 Drag & Drop An Image
 A Simple Image Viewer
 A Shaking Image
 A Digital Clock
 Drop Down List Link
 Top Drop Down Menu
 Always On Top Menu
 Inset Border Buttons
 A Description Generating Menu
 An Image Generating Menu
 A Horizontal Sliding Menu
 A Click Horizontal Sliding Menu
 Returning Cursor Co-ordinates
 Making Text Follow The Cursor
 Attaching An Image To The Cursor
text following cursor

You can instruct the browser to have a string of text follow the cursor around anywhere in the active window. We first determine the X and Y co-ordinates of the mouse pointer. Then we determine some idea a to what the text should look like and assign them with common CSS rules. Positioning is determined and the text is set to follow the pointer while the X and Y co-ordinates are being generated and passed along the bubbling order of the JavaScript functions in the HEAD of the document.

The text is actually always there – we just set it to hidden with the style.visibility attribute and to visible when we need to. The onMouseMove event handler triggers the JavaScript functions when you move the cursor on the X or Y axis one pixel. If you stay still, so will the text.

To have a finer degree of control over the rendering of the moving – if it looks jerky – just alter the amount that the X or Y axis is incremented with every iteration of the script. A smaller value will result in a smoother look, but might lag a little behind if you’re showing a lot of text trailing behind the cursor or if the computer is being used heavily. If this is a concern, increase the increment of the positioning and the text will move quicker and will stay with the cursor.

<html>
<head>

<script type="text/javascript">
function cursor(event) {
document.getElementById('trail').style.visibility="visible";
document.getElementById('trail').style.position="absolute";
document.getElementById('trail').style.left=event.clientX+10;
document.getElementById('trail').style.top=event.clientY;
}
</script>

</head>

<body onmousemove="cursor(event)">

<h1>Move the cursor over this page</h1>

<span id="trail" style="visibility:hidden">Cursor Text</span>

</body>
</html>


You can assign an image to follow the cursor as well. Just state a simple IMG tag with the same attributes given above for the textual version. The co-ordinate system works the same for text as it does for images, as it’s initially based not on the location of the text or image, but on the position of the mouse pointer.
I do not employ cookies or tracking devices of any kind