Jump to content
Sign in to follow this  
penguine

Event.pagex Undefined

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...