加入函数试试:
function document.onclick() //任意点击时关闭该控件

  with(window.event)
  { if (srcElement != document.all.divHide)
    hidePicker();
  }
}

解决方案 »

  1.   

    <style>
    input{t:expression(this.onclick=showDIV)}
    body{b:expression(this.onclick=checkDIV)}
    </style>
    <script>
    function showDIV()
    {
       var d=document.createElement('div');
       d.id='newDIV';
       d.style.position='absolute';
       d.style.top='150px';
       d.style.left='200px';
       d.style.width='200px';
       d.style.height='200px';
       d.style.backgroundColor='#FF0000';
       document.body.appendChild(d);
       d.onclick=function(){cancelBody()};
       event.cancelBubble=true;
    }
    function checkDIV()
    {
       var d=document.getElementById('newDIV');
       if(d!=null&&typeof(d)!='undefined')
         d.style.display='none';
    }
    function cancelBody()
    {
       event.cancelBubble=true;
    }
    </script>
    <body>
    <input type="button" name="Submit" value="显示层">
    </body>
    </html>
      

  2.   

    baiyunfei(大虾们,可要记住:星星越多,责任越大!) 谢谢,但是加入了之后,层都不会显示出来
      vivianfdlpw()  谢谢,但是当点击层再点层以外的地方就没有隐藏层
      

  3.   

    vivianfdlpw,请问一下 cancelBody()这个起什么作用,我查了dhtml好像没找到
      

  4.   

    cancelBody() 了解,自定义的,没注意看,呵
      

  5.   

    修正了一下:<style>
    input{t:expression(this.onclick=showDIV)}
    body{b:expression(this.onclick=checkDIV)}
    </style>
    <script>
    function showDIV()
    {
       if(!document.getElementById('newDIV'))
       {
       var d=document.createElement('div');
       d.id='newDIV';
       d.style.position='absolute';
       d.style.top='150px';
       d.style.left='200px';
       d.style.width='200px';
       d.style.height='200px';
       d.style.backgroundColor='#FF0000';
       document.body.appendChild(d);
       d.onclick=function(){cancelBody()};
      }
      else
      {
      document.getElementById('newDIV').style.display='';
      }
      event.cancelBubble=true;
    }
    function checkDIV()
    {
       
       var d=document.getElementById('newDIV');
       if(d!=null&&typeof(d)!='undefined')
         d.style.display='none';
    }
    function cancelBody()
    {
       event.cancelBubble=true;
    }
    </script>
    <body>
    <input type="button" name="Submit" value="显示层">
    </body>
    </html>
      

  6.   

    vivianfdlpw,谢谢
    <style>
    //input{t:expression(this.onclick=showDIV)}
    body{b:expression(this.onclick=checkDIV)}
    </style>那不是每个页面都得加上才能触发,由于程序页面使用比较多的地方,所以不能在文档中添加代码,只能在以下的js修改(有没有办法只修改js,不用再动其它地方)
    function showMenu(){
    var obj=window.event.srcElement;
    var menu=document.all("menuPane");
    if (currentPane==obj) {
    if(menu.style.display==""){
    menu.style.display="none";
    return;
    }
    }   if(!document.getElementById('newDIV'))
       {
     var d=document.createElement('div');
     d.id='newDIV';
     d.style.position='absolute';
     d.style.top='150px';
     d.style.left='200px';
     d.style.width='200px';
     d.style.height='200px';
     //d.style.backgroundColor='#FF0000';
     document.body.appendChild(d);
     d.onclick=function(){cancelBody()};
     }
     else
    {
     document.getElementById('newDIV').style.display='';
    }
    event.cancelBubble=true;
    var d=document.getElementById('newDIV');
    d.innerHTML=menu.innerHTML;
    var scrollTop=document.all("contentpane").scrollTop;
    d.style.left=window.event.clientX-window.event.offsetX-2;
    d.style.top=window.event.clientY-window.event.offsetY+16+scrollTop;
    d.style.display="";
    currentPane=obj; /*备份原来的
             var scrollTop=document.all("contentpane").scrollTop;
    menu.style.left=window.event.clientX-window.event.offsetX-2;
    menu.style.top=window.event.clientY-window.event.offsetY+16+scrollTop-26;
    menu.style.display="";
    currentPane=obj;*/
    }