<!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>
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}</script>
<title>无标题文档</title>
<style type="text/css">
<!--
.emenu {
background-image:  url(tree/sub.gif);
background-repeat: no-repeat;
padding-left: 44px;
cursor: hand;
}
.submenu {
padding-left: 24px;
}
.file {
background-image:  url(tree/folder1.gif);
background-repeat: no-repeat;
padding-left: 18px;
cursor: hand;
}
-->
</style>
</head><body>
<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="emenu" onMouseUp="with(findObj('blueide')) if (style.display=='none'){style.display='';this.style.backgroundImage='url(sub.gif)'}else {style.display='none';this.style.backgroundImage='url(plus.gif)'}">根</td>
  </tr>
  <tr id="blueidea">
    <td class="submenu" ><table width="200" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="emenu" onMouseUp="with(findObj('forums')) if (style.display=='none'){style.display='';this.style.backgroundImage='url(sub.gif)'}else {style.display='none';this.style.backgroundImage='url(plus.gif)'}">子目录</td>
        </tr>
        <tr id="forums">
          <td width="200" class="submenu" ><table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="file">&nbsp;</td>
              </tr>
              <tr>
                <td class="file">&nbsp;</td>
              </tr>
              <tr>
                <td class="file">&nbsp;</td>
              </tr>
          </table></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="emenu"  onMouseUp="with(findObj('lexrus')) if (style.display=='none'){style.display='';this.style.backgroundImage='url(sub.gif)'}else {style.display='none';this.style.backgroundImage='url(plus.gif)'}">ddds</td>
  </tr>
  <tr id="lexrus">
    <td class="submenu"><table width="200" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="file">&nbsp;</td>
        </tr>
        <tr>
          <td class="file">&nbsp;</td>
        </tr>
        <tr>
          <td class="file">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
</table>
<br>
</body>
</html>
这是我的代码,我想让这个菜单一开始是合起来,不是展开,怎么改,谢谢

解决方案 »

  1.   

    语法:  
    display : block | none | inline | compact | er | inline-table | list-item | run-in | table |table-caption | table-cell | table-column | table-column-group | table-footer-group | table-header-group | table-row | table-row-group 
     
    参数:  
    block :  CSS1 块对象的默认值。用该值为对象之后添加新行 
    none :  CSS1 隐藏对象。与visibility属性的hidden值不同,其不为被隐藏的对象保留其物理空间 
    inline :  CSS1 内联对象的默认值。用该值将从对象中删除行 
    compact :  CSS2 分配对象为块对象或基于内容之上的内联对象 
    er :  CSS2 指定内容在容器对象之前或之后。要使用此参数,对象必须和:after及:before 伪元素一起使用 
    inline-table :  CSS2 将表格显示为无前后换行的内联对象或内联容器 
    list-item :  CSS1 将块对象指定为列表项目。并可以添加可选项目标志 
    run-in :  CSS2 分配对象为块对象或基于内容之上的内联对象 
    table :  CSS2 将对象作为块元素级的表格显示 
    table-caption :  CSS2 将对象作为表格标题显示 
    table-cell :  CSS2 将对象作为表格单元格显示 
    table-column :  CSS2 将对象作为表格列显示 
    table-column-group :  CSS2 将对象作为表格列组显示 
    table-header-group :  CSS2 将对象作为表格标题组显示 
    table-footer-group :  CSS2 将对象作为表格脚注组显示 
    table-row :  CSS2 将对象作为表格行显示 
    table-row-group :  CSS2 将对象作为表格行组显示 但一般只用 document.all.divID.style.display="none" 或 document.all.divID.style.display=""
      

  2.   

    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    </head><body bgcolor="#FFFFFF">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script>
    // Example: obj = findObj("image1");
    function findObj(theObj, theDoc)
    {
      var p, i, foundObj;
      
      if(!theDoc) theDoc = document;
      if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
      {
        theDoc = parent.frames[theObj.substring(p+1)].document;
        theObj = theObj.substring(0,p);
      }
      if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
      for (i=0; !foundObj && i < theDoc.forms.length; i++) 
        foundObj = theDoc.forms[i][theObj];
      for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
        foundObj = findObj(theObj,theDoc.layers[i].document);
      if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
      
      return foundObj;
    }</script>
    <title>无标题文档</title>
    <style type="text/css">
    <!--
    .emenu {
    background-image:  url(tree/sub.gif);
    background-repeat: no-repeat;
    padding-left: 44px;
    cursor: hand;
    }
    .submenu {
    padding-left: 24px;
    }
    .file {
    background-image:  url(tree/folder1.gif);
    background-repeat: no-repeat;
    padding-left: 18px;
    cursor: hand;
    }
    -->
    </style>
    </head><body>
    <table width="200" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="emenu" onMouseUp="with(findObj('blueide')) if (style.display=='none'){style.display='';this.style.backgroundImage='url(sub.gif)'}else {style.display='none';this.style.backgroundImage='url(plus.gif)'}">根</td>
      </tr>
      <tr id="blueidea">
        <td class="submenu" ><table width="200" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td class="emenu" onMouseUp="with(findObj('forums')) if (style.display=='none'){style.display='';this.style.backgroundImage='url(sub.gif)'}else {style.display='none';this.style.backgroundImage='url(plus.gif)'}">子目录</td>
            </tr>
            <tr id="forums" style="display:none"> //在此处加了个display:none
              <td width="200" class="submenu" ><table width="200" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td class="file">&nbsp;4</td>
                  </tr>
                  <tr>
                    <td class="file">&nbsp;5</td>
                  </tr>
                  <tr>
                    <td class="file">&nbsp;6</td>
                  </tr>
              </table></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td class="emenu"  onMouseUp="with(findObj('lexrus')) if (style.display=='none'){style.display='';this.style.backgroundImage='url(sub.gif)'}else {style.display='none';this.style.backgroundImage='url(plus.gif)'}">ddds</td>
      </tr>
      <tr id="lexrus" style="display:none">//在此处加了个display:none
        <td class="submenu"><table width="200" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td class="file">&nbsp;1</td>
            </tr>
            <tr>
              <td class="file">&nbsp;2</td>
            </tr>
            <tr>
              <td class="file">&nbsp;3</td>
            </tr>
        </table></td>
      </tr>
    </table>
    <br>
    </body>
    </html>
    </body>
    </html>
      

  3.   

    为什么要改整个网页呢? 告诉重点不就行了?如果是用<td>来实现的,那么只要一开时就设置display为"none"就可以了:
    <td ... style="display:none;" ...>
    不过用<td>还是用<tr>好, 个人认为用<div>不错