Jump to content

Event.pagex Undefined


penguine

Recommended Posts

Hi I have a div to which assigned a html page using div's innerhtml property.I wrote a function in that html page to find mouse position .I am getting event object on that function when mouse click on the div

var posx = !(window.event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); var posy = !(window.event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
but this always return undefined.Anyidea?
Link to comment
Share on other sites

Show the rest of your code for that function. We need the function definition (with the parentheses) and the lines where you define e and event.Most event handlers are called like this:

 <element onclick="my_handler(event)">

And then the handler function starts this way:

function my_handler(e) {	e = e || window.event;}

The two parts have to match

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...