...

View Full Version : Detect mouseclick anywhere outside div



sugata_bhar
06-14-2007, 06:08 AM
Hi

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

Thanks
Sugata

Rubby
06-14-2007, 07:36 AM
How about:


<body onClick="functionThatDoesSomething()" >
<div onClick="functionThatDoesNothing()" ></div>
</body>

digital-ether
06-14-2007, 10:05 AM
How about:


<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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum