先看一下网页现在的效果 
http://www.zhishishu.com/Item/134.aspx
页面上右边主体内容有三块:商品介绍,作者介绍,图书目录现在是全部显示的 页面就有可能拉升很长 现在需要跟每块的内容旁边加入一个展开,收缩案例比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 图书目录没有200px的时候 就显示全部 当点击全部展开的时候 就在那儿显示 收缩案例 是每个块都要单独的实现这个功能 网上也找了一些代码 要不 就是全部搜索隐藏的 一点都没有显示  要不 就是 不能每个单独的针对每一块 我对js不太熟 继续求助于各位大侠了 

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>test</title> 
    <style type="text/css"> 
    #box{width:500px;height:200px;overflow:hidden;border:1px solid #F00;line-height:200%;font-size:13px;padding:0 10px;margin-top:10px;}
    .show{float:right;height:18px;text-align:right;display:inline;cursor:pointer;background:#FFF;color:#F00;}
    </style> 
    <script>
    function show(t){
    t.parentNode.style.height=t.parentNode.style.height=='auto'?'200px':'auto';
    t.innerHTML=t.innerHTML=="↓展开全部↓"?"↑收回↑":"↓展开全部↓"
    }
    </script>
    </head> 
    <body><div id="box"><div class="show" onclick="show(this)">↓展开全部↓</div>
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>图书目录没有200px的时候 就显示全部 <br>当点击全部展开的时候 就在那儿显示 收缩案例 <br>是每个块都要单独的实现这个功能 <br>网上也找了一些代码 要不 就是全部搜索隐藏的 一点都没有显示  <br>要不 就是 不能每个单独的针对每一块 <br>我对js不太熟 继续求助于各位大侠了 
    </div><div id="box"><div class="show" onclick="show(this)">↓展开全部↓</div>
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>图书目录没有200px的时候 就显示全部 <br>当点击全部展开的时候 就在那儿显示 收缩案例 <br>是每个块都要单独的实现这个功能 <br>网上也找了一些代码 要不 就是全部搜索隐藏的 一点都没有显示  <br>要不 就是 不能每个单独的针对每一块 <br>我对js不太熟 继续求助于各位大侠了 
    </div>
    </body> 
    </html>
      

  2.   

    我再顶一下前去 
    L上的可以简单的实现
    但是有个问题
    当没有200px的时候问题就出来了
      

  3.   

    看看是不是这样
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>test</title> 
    <style type="text/css"> 
    #box{width:500px;height:auto;overflow:hidden;border:1px solid #F00;line-height:200%;font-size:13px;padding:0 10px;margin-top:10px;}
    .show{float:right;height:18px;text-align:right;display:inline;cursor:pointer;background:#FFF;color:#F00;}
    </style> 
    <script>
    function show(t){
    t.parentNode.style.height=t.parentNode.style.height=='auto'?'200px':'auto';
    t.innerHTML=t.innerHTML=="↓展开全部↓"?"↑收回↑":"↓展开全部↓"
    }
    window.onload=function(){
    var divs = document.getElementsByTagName("DIV");
    for(var i=0;i<divs.length;i++){
    if(divs[i].id=="box"){
    if(divs[i].offsetHeight>200){
    divs[i].style.height = "200px";
    }else{
    divs[i].firstChild.style.display = "none";
    }
    }
    }
    };
    </script>
    </head> 
    <body><div id="box"><div class="show" onclick="show(this)">↓展开全部↓</div>
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>图书目录没有200px的时候 就显示全部 <br>当点击全部展开的时候 就在那儿显示 收缩案例 <br>是每个块都要单独的实现这个功能 <br>网上也找了一些代码 要不 就是全部搜索隐藏的 一点都没有显示  <br>要不 就是 不能每个单独的针对每一块 <br>我对js不太熟 继续求助于各位大侠了 
    </div>
    <div id="box"><div class="show" onclick="show(this)">↓展开全部↓</div>
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>图书目录没有200px的时候 就显示全部 <br>当点击全部展开的时候 就在那儿显示 收缩案例 <br>
    </div>
    <div id="box"><div class="show" onclick="show(this)">↓展开全部↓</div>
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>图书目录没有200px的时候 就显示全部 <br>当点击全部展开的时候 就在那儿显示 收缩案例 <br>是每个块都要单独的实现这个功能 <br>网上也找了一些代码 要不 就是全部搜索隐藏的 一点都没有显示  <br>要不 就是 不能每个单独的针对每一块 <br>我对js不太熟 继续求助于各位大侠了 
    </div>
    </body> 
    </html>
      

  4.   

    纯JS版
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>test</title> 
    <style type="text/css"> 
    .box{width:500px;overflow:hidden;border:1px solid #F00;line-height:200%;font-size:13px;padding:0 10px;margin-top:10px;}
    .show{float:right;height:18px;text-align:right;display:inline;cursor:pointer;background:#FFF;color:#F00;}
    </style> 
    <script>
    function show(t){
    t.parentNode.style.height=t.parentNode.style.height=='auto'?'200px':'auto';
    t.innerHTML=t.innerHTML=="↓展开全部↓"?"↑收回↑":"↓展开全部↓"
    }
    window.onload=function(){
    n=3
    for(i=1;i<=n;i++){
    var box=document.getElementById("box"+i);
    if(box.clientHeight>200){
    box.innerHTML='<div class="show" onclick="show(this)">↓展开全部↓</div>'+box.innerHTML
    box.style.height="200px";
    }
    }
    }
    </script>
    </head>
    <body><div class="box" id="box1">
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>图书目录没有200px的时候 就显示全部 <br>当点击全部展开的时候 就在那儿显示 收缩案例 <br>是每个块都要单独的实现这个功能 <br>网上也找了一些代码 要不 就是全部搜索隐藏的 一点都没有显示  <br>要不 就是 不能每个单独的针对每一块 <br>我对js不太熟 继续求助于各位大侠了 
    </div><div class="box" id="box2">
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>
    </div><div class="box" id="box3">
    页面上右边主体内容有三块:商品介绍,作者介绍,图书目录 <br>现在是全部显示的 页面就有可能拉升很长 <br>现在需要跟每块的内容旁边加入一个展开,收缩案例 <br>比如当图书目录的内容高度超过了200px的时候就只显示200px 跟着显示一个展开 <br>图书目录没有200px的时候 就显示全部 <br>当点击全部展开的时候 就在那儿显示 收缩案例 <br>是每个块都要单独的实现这个功能 <br>网上也找了一些代码 要不 就是全部搜索隐藏的 一点都没有显示  <br>要不 就是 不能每个单独的针对每一块 <br>我对js不太熟 继续求助于各位大侠了 
    </div>
    </body> 
    </html>
      

  5.   


    //看看我的js代码把ClassModel = 
    {
    create : function()
     {
    return function()
    {
    this.construct.apply(this, arguments);
    }
     }
    }
    Extend = function(desc, src)
    {
    for(var c in src)
    {
    desc[c] = src[c];
    }
    return desc;
    }
    Object.prototype.extend = function(src) 
    {
    return Extend.apply(this, [this, src]);
    }/**********************************************************/
    var windows = ClassModel.create();
    windows.prototype =
    {
    construct : function(jsonObject)
    {
    this.title = jsonObject.title;
    this.width = jsonObject.width;
    this.height = jsonObject.height;
    this.titleColor = jsonObject.titleColor;
    this.backgroundColor = jsonObject.backgroundColor;
    this.LwHeight = (document.body.clientHeight - this.width) / 2;  //让div在屏幕的中间
    this.LwWidth = (document.body.clientWidth - this.height) / 2;  //让div在屏幕的中间
    this.content = jsonObject.content;
    var loginWindow = this.createLoginBody();

    var title = this.createLoginTitle();
    loginWindow.appendChild(title);

    var cont = this.createContent();
    loginWindow.appendChild(cont);

    document.getElementById("mask").style.visibility = "visible";

    document.body.appendChild(loginWindow);

    }, createLoginBody: function() //创建登陆框, 即整个框
    {

    var loginWindow = document.createElement("div");
    loginWindow.id = "dialog";
    with(loginWindow.style)
    {
    border = "1px solid white";
    zIndex = "3";
    position = "absolute";
    width = this.width + "px";
    height = this.height + "px";
    top = this.LwHeight + "px";
    left = this.LwWidth + "px";
    backgroundColor = this.backgroundColor;

    }

    return loginWindow;
    },
    createLoginTitle:function() //创建 标题 即效果图的黑色标题
    {
    var title = document.createElement("div");
    var table = document.createElement("table");
    var tbody = document.createElement("tbody");
    var tr = document.createElement("tr");
    var td_1 = document.createElement("td");
    var td_2 = document.createElement("td"); var close = document.createElement("img");
    close.src = "close.jpg";
    close.onclick = function()
    {
    document.body.removeChild(title.parentNode);
    document.getElementById("mask").style.visibility = "hidden";

    }

    td_1.innerHTML = this.title;
    with(title.style)
    {
    width = "100%";
    height = this.height / 12 + "px";
    backgroundImage = "url('titleBg.jpg')";
    }
    with(table.style)
    {
    color = "white";
    fontSize = "10pt";
    width = "100%";
    backgroundImage = "url('titleBg.jpg')";
    color = "black";
    fontWeight = "bold";
    }
    td_2.style.textAlign = "right";
    td_2.appendChild(close);
    tr.appendChild(td_1);
    tr.appendChild(td_2);
    tbody.appendChild(tr);
    table.appendChild(tbody);
    title.appendChild(table); return title;

    },
    createContent : function()
    {

    var div = document.createElement("div");

    if(typeof(this.content) == 'string')
    {
    div.innerHTML = this.content;
    }else
    {
    div.appendChild(this.content);
    }
    with(div.style)
    {
    paddingLeft = "80px";
    paddingTop = "50px";
    float = "left";
    width = "100%";
    }
    return div;
    }
    }
      

  6.   

    谢谢各位支持 
    已经用bing475879749的方法了
    结贴
      

  7.   

     /******************************************************************
           功能:  将金额值(long)转换成字符串(按0.00的格式)
           参数: String       long      金额值(以分为单位)
          返回值: String (以元为单位)
         *******************************************************************/
        public static String LongToMoney(long lMoney)
        {
            double dMoney = (double)lMoney/100;
            java.text.DecimalFormat nfMoney = new java.text.DecimalFormat("0.00");
            return nfMoney.format(dMoney);
        }
      

  8.   

    索引是表的一个概念部分,用来提高检索数据的效率. 实际上,ORACLE使用了一个复杂的自平衡B-tree结构. 通常,通过索引查询数据比全表扫描要快. 当ORACLE找出执行查询和Update语句的最佳路径时, ORACLE优化器将使用索引. 同样在联结多个表时使用索引也可以提高效率. 另一个使用索引的好处是,它提供了主键(primary key)的唯一性验证. 
    除了那些LONG或LONG RAW数据类型, 你可以索引几乎所有的列. 通常, 在大型表中使用索引特别有效. 当然,你也会发现, 在扫描小表时,使用索引同样能提高效率. 
    虽然使用索引能得到查询效率的提高,但是我们也必须注意到它的代价. 索引需要空间来 
    存储,也需要定期维护, 每当有记录在表中增减或索引列被修改时, 索引本身也会被修改. 这意味着每条记录的INSERT , DELETE , UPDATE将为此多付出4 , 5 次的磁盘I/O . 因为索引需要额外的存储空间和处理,那些不必要的索引反而会使查询反应时间变慢. 译者按: 
    定期的重构索引是有必要的. 
    ALTER INDEX <INDEXNAME> REBUILD <TABLESPACENAME>