function addEvent( elem, evt, callback ) {
if ( elem.addEventListener ) {
elem.addEventListener( evt, callback, false );
} else if ( elem.attachEvent ) {
elem.attachEvent( "on" + evt, callback );
}
}
function clearEvent( e ) {
e = e || window.event
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
}
window.onload = function() {
var elem = document.getElementById('hoverthis');
addEvent( elem, "mouseover", function() {
var box = document.getElementById('box');
box.className = 'active';
box.style.display = 'block';
return false;
});
addEvent( elem, "click", function( e ) {
clearEvent( e );
return false;
});
addEvent( document.getElementById('box'), "click", function( e ) {
clearEvent( e );
return false;
});
addEvent( document, "click", function() {
var box = document.getElementById('box');
box.className = '';
box.style.display = 'none';
return false;
});
};
примерно так)