ho riprovato con alcune modifiche suggerite da Xinod ma onmouseout scatta subito appena entro nel div con id 'menu':
ho usato onmouseout e il while
codice:
window.onload = function(){menuInit('menu','bott')}
function menuInit(m,b){
var stato = 'none';
var menu = document.getElementById(m);
menu.style.display = stato;
// click bottone apre/chiude
var bott = document.getElementById(b);
bott.onclick = function(){
stato = (menu.style.display=='none' || menu.style.display == '')?'block':'none';
menu.style.display = stato;
if(stato == 'block'){
menu.onmouseout = obj;
}
return false;
}
function obj(e){
if(!e)e=window.event;
var src=e.target?e.target:e.srcElement;
//alert(src + ',' + src.parentNode)
while(src = src.parentNode) {
menu.style.display = 'none';
}
}
}