日期:2014-05-16  浏览次数:20340 次

帮忙修改个小代码
下面的代码是一个DIV层伸缩的效果,  现在问题是只伸的时候有动画,请大大们帮修改下缩的时候也有动画,谢谢哦。。  还有就是那个时间控制, 最小只能1.1吗  能再慢一点么?



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>kissy</title>

<style>
*{ margin: 0; padding: 0;}
html{overflow:hidden;border:0px;}
body {margin: 0px;padding:0px;border:0px;overflow:hidden;font:12px Arial, Helvetica, sans-serif;background-color:Transparent;}
.main{width: 100%;overflow: hidden;position: relative;}
.title h3{background: #f9f9f9;border-bottom: 1px solid #DDD;line-height: 25px;height: 25px;overflow: hidden;zoom: 1;padding-left: 10px;padding-top: 6px;}
.title span{float:right;margin-top:-25px;}
#layer-body{height:0;}
</style>

<script type="text/javascript">
/*
    函数名称: Scroll
    Scroll(obj, h, s)
    参数说明:
        obj,[object]  id值或对象.     必需
          h,[height]  展开后的高度.   可选(默认为200px)
          s,[speed]   展开速度,值越小展开速度越慢. 可选(默认为1.2){建议取值为1.1到2.0之间[例如:1.17]}.
    函数返回值:
        true    展开(对象的高度等于展开后的高度)
        false   关闭(对象的高度等于原始高度)
*/
function Scroll(obj, h, s){
    if(obj == undefined){return false;}
    var h = h || 262;
    var s = s || 1.1;
    var obj = typeof(obj)=="string"?document.getElementById(obj):obj;
    var status = obj.getAttribute("status")==null;
    var oh = parseInt(obj.offsetHeight);
    obj.style.height = oh;
    obj.style.display = "block";
 obj.style.overflow = "hidden";
    if(obj.getAttribute("oldHeight") == null){
        obj.setAttribute("oldHeight", oh);
    }else{
        var oldH = Math.ceil(obj.getAttribute("oldHeight"));
    }
    var reSet = function(){
        if(status){
            if(oh < h){
                oh = Math.ceil(h-(h-oh)/s);
                obj.style.height = oh+"px";
            }else{
                obj.setAttribute("status",false);