views:

79

answers:

7

I have this code and wanted to know what all those event.client do?

  document.body.ondblclick = function(){
    var dclick = false;
    if(event.clientX > 8 && event.clientX < 204){
        if((event.clientY > 88 && event.clientY < 129) ||
            (event.clientY > 129 && event.clientY < 171) ||
            (event.clientY > 172 && event.clientY < 212) ||
            (event.clientY > 213 && event.clientY < 255) ||
            (event.clientY > 256 && event.clientY < 297) ||
            (event.clientY > 297 && event.clientY < 339)){
            dclick = true;
        }
    }
    }
+3  A: 

It appears to be attempting to detect double clicks at certain locations (coordinates) within the browser window.

BoltClock
+2  A: 

The event object contains information about where the click took place. clientY will be the distance in pixels from the top left down, and clientX will be the distance right from the top left.

Kevin Sedgley
+5  A: 

Its trying to determine if someone has double clicked the mouse on a certain part of the body. event.clientX and event.clientY are the X-Y coordinates of the mouse.

Pat
+1  A: 

It's checking whether user clicks on specific coordinate

jancrot
+1  A: 

event.clientY and event.clientX are the co-ordinates of the mouse on the page, so, if the mouse is within these

dclick is defined within the function, and it does nothing more with it, so it basically does nothing.

I could not say more without context.

Raskolnikov
+1  A: 

The clientX and clientY properties give the location of the click in window space: that is, without regard to scrolling. For instance, if clientX = 0 and clientY = 0, the click occurred at the top-left corner of the window.

In the future, MDN is a good javascript reference.

Also, consider sending the code this came from to The Daily WTF.

David M.
A: 

They return the horizontal and vertical coordinates of an event. Say a mouse click ? Looking at your code I think this returns a flag as true to some other event depending on some certain areas of the screen/browser being clicked by the user. More on this here https://developer.mozilla.org/en/DOM/event.clientX

Popo