Determine if user clicked outside of layer

Discussion in 'Web Design and Development' started by EricBrian, Jan 25, 2010.

  1. EricBrian macrumors 6502a

    EricBrian

    Joined:
    Jul 30, 2005
    #1
    So, I have this layer that is 400px by 200px. I need to know if the user clicks outside of this layer. Anybody have a link to a page that explains how to trap that click?

    Thanks. :)
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You may want to look up event delegation for JavaScript. You might be able to utilize it for this. You can just place a onclick event for the document.window and see if a click in your area also occurs at that same time. A trickier method would involve capturing the 4-corners of your area and find the mouse coordinates and do some simple math to see if you're inside the box.
     

Share This Page