Posted By

pablazo on 12/11/06


Tagged

javascript html capas tablas


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Capa con ancho fijo


 / Published in: JavaScript
 

  1. <!--- tooltip.js -->
  2. // position of the tooltip relative to the mouse in pixel //
  3. var offsetx = -12;
  4. var offsety = 8;
  5.  
  6. function newelement(newid)
  7. {
  8. if(document.createElement)
  9. {
  10. var el = document.createElement('div');
  11. el.id = newid;
  12. with(el.style)
  13. {
  14. display = 'none';
  15. position = 'absolute';
  16. }
  17. el.innerHTML = '&nbsp;';
  18. document.body.appendChild(el);
  19. }
  20. }
  21. var ie5 = (document.getElementById && document.all);
  22. var ns6 = (document.getElementById && !document.all);
  23. var ua = navigator.userAgent.toLowerCase();
  24. var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
  25. function getmouseposition(e)
  26. {
  27. if(document.getElementById)
  28. {
  29. var iebody=(document.compatMode &&
  30. document.compatMode != 'BackCompat') ?
  31. document.documentElement : document.body;
  32. pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
  33. pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
  34. mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
  35. mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;
  36.  
  37. var lixlpixel_tooltip = document.getElementById('tooltip');
  38. lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
  39. lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
  40. }
  41. }
  42. function tooltip(tip)
  43. {
  44. if(!document.getElementById('tooltip')) newelement('tooltip');
  45. var lixlpixel_tooltip = document.getElementById('tooltip');
  46. lixlpixel_tooltip.innerHTML = tip;
  47. lixlpixel_tooltip.style.display = 'block';
  48. document.onmousemove = getmouseposition;
  49. }
  50. function exit()
  51. {
  52. document.getElementById('tooltip').style.display = 'none';
  53. }
  54. <!-- fin tooltip.js -->
  55.  
  56. <div style="width: 52px; overflow: auto; overflow-x:hidden" onmouseover="tooltip('<%=textoCelda%>');" onmouseout="exit();" >
  57. <%=textoCelda%>
  58. </div>

Report this snippet  

You need to login to post a comment.