PDA

View Full Version : onunfocus? or eq


AaronCampbell
07-09-2004, 01:23 PM
I have a div that starts out hidden, and when someone clicks on a link, it appears near that link (it has a form in it). If the user submits the form, the div goes away, because it submits to itself, and when the page reloads...the div is hidden. The problem is, if the user changes their mind, their natural reatction seems to be...click somewhere else, to make it go away. The problem is, I don't know how to tell if a user clicks 'anywhere except the div'. Any ideas?

agent002
07-09-2004, 01:32 PM
This should capture a click that wasn't made in a specific div:
document.onclick = function(e){
var o = (e && e.target)? e.target : event.srcElement;
if(!o.id || o.id != 'div id here'){
// a click that wasn't in the specific div!
}
}