This works for me, but it's a bit ugly... :)

Event.localPointer = function(event){
  var p = [Event.pointerX(event), Event.pointerY(event)];
  var element = arguments[1] || Event.element(event);
  var e = Position.page($(element));
  return [
    p[0]-(e[0]+(window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0)),
    p[1]-(e[1]+(window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop  || 0))];
}

Best,
Thomas

Am 21.07.2006 um 13:42 schrieb Michael Siebert:

Hello again,
im searching for a way to find the relative coordinates of a mouse click.if you dont understand what i mean: i have a DIV of a certain size positioned somewhere on the site. the user can click on that div and the app needs to know where exactly that is, the upper left corner of the div being (0, 0) and the lower right being eg. (200, 135)

i tried something like
x = Math.round(e.pageX - e.originalTarget.offsetLeft)
y = Math.round(e.pageY - e.originalTarget.offsetTop);

but that doesnt work as i have found out a few minutes before (and ie an opera dont have originalTarget)

can you give me a hint?

greetz

--
Michael Siebert <[EMAIL PROTECTED]>

www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
_______________________________________________
Rails-spinoffs mailing list

--
Thomas Fuchs
wollzelle


questentier on AIM
madrobby on irc.freenode.net
 
http://www.fluxiom.com :: online digital asset management
http://script.aculo.us :: Web 2.0 _javascript_
http://mir.aculo.us :: Where no web developer has gone before




_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to