用 document.getElementById()
就可以不用判断 ns, ie

解决方案 »

  1.   

    谢谢楼上的回复
    你说的没有错,用getElementById可以获取div 的id
    可是,我想知道的是在“显示”、“隐藏”究竟错在哪里?
    再次感谢
      

  2.   

    obj.display = "block"
    试试将上面的全部改成
     obj.display = ""
      

  3.   

    还有呀,display是style里面的属性。obj.style.display="";也试试吧
      

  4.   

    if (obj.display = "none") obj.display = "block"
    这儿错了,如果判断用==而不是=
      

  5.   

    回 pli0825(紫飞絮) :obj.display = "block"
    试试将上面的全部改成
     obj.display = ""我试着改过来,还是不行
    另外,你说的display是style里面的属性,这没有错
    这也就是我在代码中分成ns和ie来写的原因
      

  6.   

    回xxuu503(学会糜烂和挥霍,恐惧不安和堕落!) if (obj.display = "none") obj.display = "block"
    这儿错了,如果判断用==而不是=谢谢你的回复,那儿是错了(呵呵,我说我是新手,这应该是最基本的常识了,还是错了)
    可是,我改过来了,还是不行
    这说明错误不在这里?
      

  7.   

    function checkchange()
      {
        if( document.getElementById('aaa').style.display=='none')
            document.getElementById('aaa').style.display='';
        else
            document.getElementById('aaa').style.display='none';       
         
      }
      

  8.   

    if (obj.display != "block") obj.display = "block"
    else if (obj.display == "block") obj.display = "none"这样总该是对的吧
      

  9.   

    上面两位朋友的方法,我都试过来还是不行我把html的代码也写出来大家来看一下这里是
    <a style="cursor:hand" onClick="openclose(aaa)">单击这里显示/隐藏</a><div id=aaa>这里是显示/隐藏的内容</div>js的代码:
    ns4 = (document.layers)? true:false
    ie4 = (document.all)? true:false
    function openclose(item){
     if (ns4)
     {
      obj = document.item
      if (obj.display = "none") obj.display = "block"
      else if (obj.display = "block") obj.display = "none"
     }
     if (ie4)
     {
      obj = item.style
      if (obj.display = "none") obj.display = "block"
      else obj.display = "none"
     }
    }
    各位朋友帮忙给看看吧
      

  10.   


    <table style="cursor : hand" onClick="return chg_chnl('supplier')" border=0 cellpadding=0 cellspacing=0 width="100%">
    <tr>
    <td align="center"><strong><font color="#FFFFFF" size="3"><span>供应商管理</span></font></strong></td>
    <td align="center"><div id="div_supplier" class="jd">6</div></td>
    </tr>
    <tr>
    <TD height=1 bgcolor="#EFEFEF" colspan=2><img src="" height=1 width=100 border=0></td>
    </tr>
    </table>
    <div id="supplier" style="display : none">
    <table width="100%" border="0" cellpadding=1 cellspacing=1>
    <% If inStr("Director,Supervisor,MarketRecorder,Programmer",session("adminClass"))>0 Then %>
    <tr>
    <td class="menu_title" align="center" onmouseover="this.className='menu_title2'" onmouseout="this.className='menu_title'" style="cursor:hand" background="image/menudown.gif" height="22"><a href="ViewSupplier.asp" target="main"><span>供应商管理</span></a></td>
    </tr>
    <%end if%>
       <% If inStr("Director,Supervisor,SaleManagement,Programmer",session("adminClass"))>0 Then %>
    <tr>
    <td class="menu_title" align="center" onmouseover="this.className='menu_title2'" onmouseout="this.className='menu_title'" style="cursor:hand" background="image/menudown.gif" height="22"><a href="../supplier/supplier_products.asp" target="main"><span>供应商产品</span></a></td>
    </tr>
    <%end if%>
       <% If inStr("Director,Supervisor,Programmer",session("adminClass"))>0 or inStr(UCase(elect),UCase(session("username")))>0  Then %>
    <tr>
    <td class="menu_title" align="center" onmouseover="this.className='menu_title2'" onmouseout="this.className='menu_title'" style="cursor:hand" background="image/menudown.gif" height="22"><a href="../supplier/supplier_electproductsshow.asp" target="main"><span>供应商电子产品</span></a></td>
    </tr>
    <%end if%>
    </table>
    </div><table style="cursor : hand" onClick="return chg_chnl('xinxi')" border=0 cellpadding=0 cellspacing=0 width="100%">
    <tr>
    <td align="center"><strong><font color="#FFFFFF" size="3"><span>登陆信息</span></font></strong></td>
    <td align="center"><div id="div_xinxi" class="jd">6</div></td>
    </tr>
    <tr>
    <TD height=1 bgcolor="#EFEFEF" colspan=2><img src="" height=1 width=100 border=0></td>
    </tr>
    </table>
    <div id="xinxi" style="display : none">
            <table cellspacing="0" cellpadding="0" width="135" align="center">
              <tr>
                <td height="20"><br>
                  网 址:<%= Request.ServerVariables("SERVER_NAME")
     %><br>
                  日 期:<%= FormatDateTime(now(),1) %><br>
                  时 间:<%= FormatDateTime(now(),4) %><br>
                  管理员:<%= session("username") %><br>
                  级 别:<%= session("adminClass") %><br>
                  真实IP:<%= Request.ServerVariables("REMOTE_ADDR")
     %> <br>
                  <br>
                </td>
              </tr>
      <% If inStr("Director,Programmer",session("adminClass"))>0 Then %>   
              <tr>
                <td valign=top><a href="count1\main.asp" target="main">※ 总体数据</a> <br>
                  <a href="count1\tj_all.asp" target="main">※ 详细记录</a> <br>
                  <a href="count1\tj_hour.asp" target="main">※ 24小时统计</a> <br>
                  <a href="count1\tj_day.asp" target="main">※ 日统计</a> <br>
                  <a href="count1\tj_week.asp" target="main">※ 周统计</a> <br>
                  <a href="count1\tj_month.asp" target="main">※ 月统计</a> <br>
                  <a href="count1\tj_come.asp" target="main">※ 来路统计</a> <br>
                  <a href="count1\tj_page.asp" target="main">※ 被访页面</a> <br>
                  <a href="count1\tj_ip.asp" target="main">※ IP统计</a> <br>
                  <a href="count1\tj_soft.asp" target="main">※ 客户端软件</a> <br>
                  <a href="count1\tj_where.asp" target="main">※ 访问者地区</a> </td>
              </tr>   
              <tr height=60 >
                <td valign=top><a href="count1\tj_search.asp" target="main">自定义统计</a>
    <%set conn=server.createobject("adodb.connection")
    DBPath = Server.MapPath("count1\count.mdb")
    conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
    Set rs = Server.CreateObject("ADODB.Recordset")

    sql="select top 2 * from save"
    rs.Open sql,conn,1,1
    do while not rs.EOF
    %>
                  <br>
    <a href="count1\tj_searchgo.asp?wherestr=<%=server.URLEncode(rs("wherestr"))%>&outtype=<%=server.URLEncode(rs("outtype"))%>&name=<%=server.URLEncode(rs("name"))%>&content=<%=server.URLEncode(rs("content"))%>" target="main">※ <%=left(rs("name"),6)%></a> <br>
    &nbsp; &nbsp; &nbsp; &nbsp; <a href="count1\tj_search.asp" target="main">更多...</a>
    <%
    rs.MoveNext
    loop
    rs.Close
    set rs=nothing
    conn.Close
    set conn=nothing
    %>
                </td>
              </tr>
      <% End If %>
            </table>
    </div></td>
      </tr>
    </table><script language="JavaScript" type="text/javascript">
    function chg_chnl(chnl){
    if(document.all){
    supplier.style.display = 'none'; div_supplier.innerHTML = '6';
    xinxi.style.display = 'none'; div_xinxi.innerHTML = '6';
    switch(chnl){ case 'supplier':
    supplier.style.display = ''; div_supplier.innerHTML = '5'; break;
    case 'xinxi':
    xinxi.style.display = ''; div_xinxi.innerHTML = '5'; break;
    case 'exit':
    top.location.href = 'logout.asp'; break;
    default:
    xinxi.style.display = ''; break;
    }
    }
    return false;
    }
    </script>
      

  11.   

    object.style.display你少了个style还有==的错误也要补上去
      

  12.   

    你的问题简单来说就是
    <div id="divid" style="display : none">abcdefg</div>
    <script>
    //条件你自己去写
    divid.style.display = ''
    divid.style.display = 'none'
    </script>
      

  13.   

    你的问题简单来说就是
    <div id="divid" style="display : none">abcdefg</div>
    <script>
    //条件你自己去写
    document.all.divid.style.display = ''
    document.all.divid.style.display = 'none'
    </script>
      

  14.   

    现在可以了谢谢,楼上的朋友
    在您的再三帮助下,终于可以了
    nnd,搞了一个早上另外也要谢谢其余各位朋友的热心回复