Или так:
<!DOCTYPE HTML>
<html>
<head> </head>
<body>
<input id="test" type="text">
<div id="menu" style="border: 1px solid #555; display: none; height: 100px; width: 170px"></div>
<script>
var menuIsHide = true;
window.onclick = test.onblur = function(e) {
var self = e.target;
if(e.type == 'blur' || (self.id == 'test' == menuIsHide)) {
menu.style.display = menuIsHide ? 'block' : 'none';
menuIsHide = !menuIsHide;
}
};
</script>
</body>
</html>