<body onclick="if(window.event.srcElement.id !='mxh'){ document.all.mxh.style.visibility='hidden';document.all.sel.style.visibility='hidden'}">
<div id=mxh style="width:200px;height:200px;visibility:visible;background-color:blue;z-index:100" onclick="document.all.mxh.style.visibility='visible';document.all.sel.style.visibility='visible'">
<select id=sel style="visibility:visible">
<option>sdfd</option>
</select>
</div>
</body>

解决方案 »

  1.   

    可能我没表述清楚。
    我想实现的类似select,点击右侧下拉按钮,显示下拉框。
    当然这个下拉框里的东西比较多,比如说是个日历。
    如果用户点击下拉框外的其他的地方,下拉框自动隐藏。
      

  2.   

    再有,由于我是将其封装在一个由javascript写的class中,最好能不对document.body做任何操作。
      

  3.   

    <body onclick="if(window.event.srcElement.id !='mm'){ document.all.mxh.style.visibility='hidden';}">
    <table cellpadding=0 cellspacing=0 border=0>
    <tr>
    <td style="border:3px groove #eeeeee;height:19px">
    <input id=xh style="border:0px solid #080808;border-right:0px;height:18px"><input id="mm" style="font-family:Webdings;font-size:9pt;height:18px;" type=button value='6' onclick="document.all.mxh.style.visibility='visible'"></td>
    </tr>
    <tr>
    <td>
    <div id=mxh style="visibility:hidden;width:100%;border:1px solid #080808">
    <table width="100%">
    <tr onmouseover="this.style.backgroundColor='#0099ff'" onmouseout="this.style.backgroundColor=''">
    <td onclick="document.all.xh.value=this.innerText"><a href="http://lucky.myrice.com">Visit1</a></td>
    </tr>
    <tr>
    <td onmouseover="this.style.backgroundColor='#0099ff'" onmouseout="this.style.backgroundColor=''"onclick="document.all.xh.value=this.innerText"><a href="http://lucky.myrice.com">Visit2</a></td>
    </tr>
    <tr>
    <td onmouseover="this.style.backgroundColor='#0099ff'" onmouseout="this.style.backgroundColor=''"onclick="document.all.xh.value=this.innerText"><a href="http://lucky.myrice.com">Visit3</a></td>
    </tr>
    </table>
    </div>
    </td>
    </tr>
    </table>
      

  4.   

    给分,谢谢,能不能不通过body呢,
    现在我在class中需要调用
    document.body.attachEvent("onclick",this.id+".hidden()");
    这样就无法达到我封装的目的了。