Firing onclick event when clicked "anywhere" in the page
Posted on 2007-03-28
I have a div content which is visible when an image is clicked. I want that div to disappear when I click "anywhere other than the div visible" area.
I thought this logic might work: When the mouse is inside the div content, set a variable say "temp" to true (i.e. onmouseover="temp=true";), else if the mouse is outside the div content, set it to false (i.e. onmouseout="temp=false";). Now *whenever* the mouse is clicked "anywhere" in the page, look if the "temp" is true or false. If it is false, then make the div content disappear (visibility:hidden).
But I am not sure how to implement it. Please advise.