Getting click co-ordinates without using image input

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
dave1909
Forum Newbie
Posts: 22
Joined: Sat Jul 25, 2009 8:56 pm

Getting click co-ordinates without using image input

Post by dave1909 »

How can i find the position of a submit button that is clicked without using input type="image"

Is there any way of doing this without Jquery? It seems like overkill.

I dont want to use input type="image" because i've styled all my input buttons.

Is there any way to get 'submit_x' and 'submit_y' any other way? Thanks
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Getting click co-ordinates without using image input

Post by twinedev »

Well technically, you can do it with plain javascript, which isn't using jQuery ;-)

I think the more important thing to ask though is what are you trying to accomplish, do you have multiple submit buttons and want to know which one they clicked on? or specifically where on a single button you are clicking?
dave1909
Forum Newbie
Posts: 22
Joined: Sat Jul 25, 2009 8:56 pm

Re: Getting click co-ordinates without using image input

Post by dave1909 »

It's part of a browser based game, somebody suggested to me this as a way of detecting auto clickers.

I'm already using a javascript function to set hidden values in the form when a user clicks the button to prevent people using refreshing scripts.

How would i go about doing this in plain javascript then?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Getting click co-ordinates without using image input

Post by pickle »

I think you could add an onclick event listener to the body. Inside that event object should be the coordinates of the click.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply