<script language="javascript">
function sea(){
  if (wew.style.display=="none"){
wew.style.display="";
}
  else{
   wew.style.display="none";
  }
}
</script> 这 是原来的代码

解决方案 »

  1.   


    <body>
    <div id="wew" style="position:absolute; left:156px; top:113px; width:131px; height:55px; z-index:1; background-color: red; layer-background-color: #FF0000; border: 1px none #000000; display:none">dddddddddddd</div>
    111111
    </body>
    <script language="javascript">
    document.body.onclick=function(){sea()}
    function sea(){
    wew.style.display="";
    alert("sdf");
    }
    </script>
      

  2.   

    谢谢,我有一个比较特殊的程序要用到,但是我是想再创建元素这样,希望解决,但有些地方想不通,不能在文档添加代码确实是可以的,例如下面面这种方式,但是我自己还没办法解决,我有看过相应的js,是可以的 div=document.createElement("<DIV id=hide style='left:100;top:0;overflow:hidden;position:absolute;visibility:hidden'></DIV>");
    pElement.appendChild(div);
      

  3.   

    在js里定义和运行时动态添加删除div都可以的1.js里定义:
    <script language="javascript">
    document.onclick=function(){sea()}
    function sea(){
    wew.style.display="";
    alert("sdf");
    }
    </script><div id="wew" style="position:absolute; left:156px; top:113px; width:131px; height:55px; z-index:1; background-color: red; layer-background-color: #FF0000; border: 1px none #000000; display:none">dddddddddddd</div>2.动态添加:
    <script language="javascript">
    var div=document.createElement("<div id=\"wew\" style=\"position:absolute; left:156px; top:113px; width:131px; height:55px; z-index:1; background-color: red; layer-background-color: #FF0000; border: 1px none #000000;display:none\">dddddddddddd</div>");document.onclick=function(){sea()}
    function sea(){
    wew.style.display="";
    alert("sdf");
    }
    </script>
    <body>
    </body>
    <script>
    document.body.appendChild(div);
    </script>
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    function showDiv(){
    var div;
    var mydiv=document.all.divHide;
    var pElement=document.body;
    div = "<table width=\"50\" height=\"102\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FF0000\"><tr>"
    div = div+"<td>&nbsp;</td><td>sea</td></tr></table>"
    if(!mydiv)
    {
    mydiv=document.createElement("<DIV id=divHide style='left:100;top:0;overflow:hidden;position:absolute;visibility:hidden'></DIV>");
    pElement.appendChild(mydiv);
    }
    mydiv.onblur=hidePicker;
    mydiv.innerHTML="<IFRAME id=IFPicker width=100% height=100%></IFRAME>";
    //alert(mydiv.innerHTML);
    var doc=frames("IFPicker").document;
    doc.open();
    //doc.write(div);
    doc.write("<body leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 style='overflow:hidden;border:none'>"+div+"</body>");
    doc.close();
    var style=mydiv.style;
    var width=200,height=150;
    style.width=width;
    style.height=height;
    style.visibility="visible";
    mydiv.focus();
    }
    //隐藏层
    function hidePicker()
    {
    var e=document.activeElement;
    var mydiv=document.all.divHide;
    if(e.id=="IFPicker")
    {
    mydiv.focus();
    return;
    }
    mydiv.style.visibility = 'hidden';
    }
    </script>
    <title>无标题文档</title>
    </head><body>
    <input name="lookshow" type="text" id="lookshow">
    <input type="button" name="Submit" value="按钮" onClick="showDiv()"></body>
    </html>
    谢谢各位,我已经测试出来了