Advertisement
valentinegirl

image cursor

Apr 22nd, 2022
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. /*
  4. Simple Image Trail script- By JavaScriptKit.com
  5. Visit http://www.javascriptkit.com for this script and more
  6. This notice must stay intact
  7. */
  8.  
  9. var trailimage=["https://dl.dropbox.com/s/eeqh9g8bjgagfxq/hoalsbd.gif", 29.5] //image path, plus width and height
  10. var offsetfrommouse=[0,0] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
  11. var displayduration=0 //duration in seconds image should remain visible. 0 for always.
  12.  
  13. if (document.getElementById || document.all)
  14. document.write('<div id="trailimageid" style="position:fixed;visibility:visible;left:0px;top:0px;width:1px;height:1px;pointer-events:none;z-index:1000"><img src="'+trailimage[0]+'" border="0" width="'+trailimage[1]+'px" height="'+trailimage[2]+'px"></div>')
  15.  
  16. function gettrailobj(){
  17. if (document.getElementById)
  18. return document.getElementById("trailimageid").style
  19. else if (document.all)
  20. return document.all.trailimagid.style
  21. }
  22.  
  23. function truebody(){
  24. return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  25. }
  26.  
  27. function hidetrail(){
  28. gettrailobj().visibility="hidden"
  29. document.onmousemove=""
  30.  
  31. }
  32.  
  33. function followmouse(e){
  34. var xcoord=offsetfrommouse[0]
  35. var ycoord=offsetfrommouse[0]
  36. if (typeof e != "undefined"){
  37. xcoord+=e.pageX
  38. ycoord+=e.pageY
  39. }
  40. else if (typeof window.event !="undefined"){
  41. xcoord+=truebody().scrollLeft+event.clientX
  42. ycoord+=truebody().scrollTop+event.clientY
  43. }
  44. var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
  45. var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
  46. if (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight)
  47. gettrailobj().display="none"
  48. else
  49. gettrailobj().display=""
  50. gettrailobj().left=xcoord+"px"
  51. gettrailobj().top=ycoord+"px"
  52. }
  53.  
  54. document.onmousemove=followmouse
  55.  
  56. if (displayduration>0)
  57. setTimeout("hidetrail()", displayduration*1000)
  58.  
  59. </script>
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement