Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2005
    Location
    Delhi
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detect mouseclick anywhere outside div

    Hi

    Is there any way of detecting mouseclick outside anywhere in a webpage outside a particular div?

    Thanks
    Sugata

  • #2
    New Coder
    Join Date
    May 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How about:
    Code:
    <body onClick="functionThatDoesSomething()" >
    <div onClick="functionThatDoesNothing()" ></div>
    </body>

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Rubby View Post
    How about:
    Code:
    <body onClick="functionThatDoesSomething()" >
    <div onClick="functionThatDoesNothing()" ></div>
    </body>
    Like shown above, the only way to get a mouse click outside an Element is to capture it in a parent Element. The BODY will captch all mouse clicks, so you can use that.

    Then you can get the target of the event, which is the Element that the event occurred in before, it bubbled to the BODY Element.
    Fiji Web Design - where i do Joomla Web Design
    Bucabay.com - My blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •