Categories:

Home / Free JavaScripts / Mouse Cursor effects / Here

Cut & Paste Simple Image Trail

Credit: JavaScript Kit

Description: Use this script to add a simple image trail to your webpage. A single image follows the mouse around, and is configurable in the following ways:

  • Image trail can be set to disappear after x seconds (or always visible)

  • The trail's x and y offsets can be explicitly set. This allows you, for example, to set the trail to be further away from the mouse than by default.

  • Image trail automatically disappears when it's close to the document's horizontal and vertical edges, so no ugly browser scrollbars appears.

This script works in both IE4+ and NS6+. Enjoy!

Example: Move your cursor!

Directions

Step 1: Simply insert the below script into the <BODY> section of your page:

') function gettrailobj(){ if (document.getElementById) return document.getElementById("trailimageid").style else if (document.all) return document.all.trailimagid.style } function truebody(){ return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function hidetrail(){ gettrailobj().visibility="hidden" document.onmousemove="" } function followmouse(e){ var xcoord=offsetfrommouse[0] var ycoord=offsetfrommouse[1] if (typeof e != "undefined"){ xcoord+=e.pageX ycoord+=e.pageY } else if (typeof window.event !="undefined"){ xcoord+=truebody().scrollLeft+event.clientX ycoord+=truebody().scrollTop+event.clientY } var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15 var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight) if (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight) gettrailobj().display="none" else gettrailobj().display="" gettrailobj().left=xcoord+"px" gettrailobj().top=ycoord+"px" } document.onmousemove=followmouse if (displayduration>0) setTimeout("hidetrail()", displayduration*1000)

This free script provided by
JavaScript Kit

Be sure to customize  the three variables inside script.


CSS Library | JavaScript & DHTML Menus
JavaScript Tools:
Site Info


CopyRight (c) 2018 JavaScript Kit. NO PART may be reproduced without author's permission. Contact Info