23 sty 2008

Dymek nad pozycja kursora myszy

Dymek nad pozycja kursora myszy

function vDymek(tresc, ev) {
  var IE = document.all ? true : false;
  // obsługuje dla NS
  // if (!IE) document.captureEvents(Event.MOUSEMOVE);
  if (IE) {
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {

    //ev = ev || event;
    tempX = ev.pageX;
    tempY = ev.pageY;
  }

  if (tempX < 0) { tempX = 0 };
  if (tempY < 0) { tempY = 0 };
  var div = document.getElementById('dymek');

  div.style.display = 'block';
  div.style.top = tempY + 'px';
  div.style.left = tempX + 'px';
  div.innerHTML = tempX + ', ' + tempY + '; ' + tresc;
}

function hDymek() {
  var div = document.getElementById('dymek');
  div.style.display = 'none';
}
<a href onMouseOver="vDymek('tresc1', event)" onMouseOut="hDymek()">sprawdz wartosc</a>
<a href onMouseOver="vDymek('tresc2', event)" onMouseOut="hDymek()">sprawdz wartosc</a>
<div id="dymek" style="position: absolute;"></div>