faqts : Computers : Programming : Languages : JavaScript : Frames

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 2 people (0%) answered Yes
Recently 0 of 2 people (0%) answered Yes

Entry

Position in a frame...?

Jun 1st, 2006 04:29
Ostap Demkovych, carl tamleht,


For IE :

 we = window.event.srcElement;

  if ((we.offsetParent) && (we.offsetParent.tagName != "BODY")) {
    windowDX = window.event.clientX - window.event.x;
    windowDY = window.event.clientY - window.event.y;
  } else {
    windowDX = 0;
    windowDY = 0;
  }

  posX = we.offsetLeft + windowDX + document.body.scrollLeft;
  posY = we.offsetTop + windowDY + document.body.scrollTop;

For more details see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndude/html/dude04032000.asp

For  FF:
window.onclick=function mousePos(ev){...}; 
use event property: ev.layerX, ev.layerY
more info about event object
http://developer.mozilla.org/en/docs/DOM:event