Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var offsetfromcursorX=12
  2. var offsetfromcursorY=10
  3.  
  4. var offsetdivfrompointerX=10
  5. var offsetdivfrompointerY=14
  6.  
  7. document.write('<div id="tooltip"><\/div>')
  8. document.write('<img id="pointer" src="img\/arrow01.png">')
  9.  
  10. var ie=document.all
  11. var ns6=document.getElementById && !document.all
  12. var enabletip=false
  13. if (ie||ns6)
  14. var tipobj=document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : ""
  15.  
  16. var pointerobj=document.all? document.all["pointer"] : document.getElementById? document.getElementById("pointer") : ""
  17.  
  18. function ietruebody(){
  19. return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  20. }
  21.  
  22. function show(thetext, thewidth, thecolor){
  23. if (ns6||ie){
  24. if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
  25. if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
  26. tipobj.innerHTML=thetext
  27. enabletip=true
  28. return false
  29. }
  30. }
  31.  
  32. function positiontip(e){
  33. if (enabletip){
  34. var nondefaultpos=false
  35. var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
  36. var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
  37.  
  38. var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
  39. var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
  40.  
  41. var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
  42. var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
  43.  
  44. var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000
  45.  
  46. if (rightedge<tipobj.offsetWidth){
  47.  
  48. tipobj.style.left=curX-tipobj.offsetWidth+"px"
  49. nondefaultpos=true
  50. }
  51. else if (curX<leftedge)
  52. tipobj.style.left="5px"
  53. else{
  54.  
  55. tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
  56. pointerobj.style.left=curX+offsetfromcursorX+"px"
  57. }
  58.  
  59. if (bottomedge<tipobj.offsetHeight){
  60. tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
  61. nondefaultpos=true
  62. }
  63. else{
  64. tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
  65. pointerobj.style.top=curY+offsetfromcursorY+"px"
  66. }
  67. tipobj.style.visibility="visible"
  68. if (!nondefaultpos)
  69. pointerobj.style.visibility="visible"
  70. else
  71. pointerobj.style.visibility="hidden"
  72. }
  73. }
  74.  
  75. function hide(){
  76. if (ns6||ie){
  77. enabletip=false
  78. tipobj.style.visibility="hidden"
  79. pointerobj.style.visibility="hidden"
  80. tipobj.style.left="-1000px"
  81. tipobj.style.backgroundColor=''
  82. tipobj.style.width=''
  83. }
  84. }
  85.  
  86. document.onmousemove=positiontip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement