var h = 控件要显示的高度 function animateControl(ctrl) { var curH = parseFloat(ctrl.style.height); curH += 1;//自己控制下数值 if (curH < h) { setTimeout("animateControl("+ctrl+")",1000); } } //基本原理就是这样,so easy
上面的"animateControl("+ctrl+")"写错了,应该这样写"function(){animateControl(ctrl);}那个写法只能传字符串. 下面的具体些 function animateControl(ctrl,flag)//动画显示 { if (!ctrl) { return; } if (!flag) { flag = "hide"; } if (!ctrl.style.height) { ctrl.style.height = ctrl.offsetHeight; } if (!ctrl.style.top) { ctrl.style.top= getAbsolutePosition(ctrl).top;//如果你需要控件会移动的话 //就写个函数取控件的position吧. } var h = parseFloat(ctrl.style.height); var y = parseFloat(ctrl.style.top); if ("show" == flag) { h -= 5; } else if ("hide" == flag) { h += 5; } frame.style.setAttribute("height", y); if ("show" == flag) { if (document.body.parentElement.offsetHeight - parseFloat(frame.style.height) < y) { window.setTimeout(function(){animatControl(ctrl,"show")}, 100); } } else if ("hide" == flag) { if (h > 0) { window.setTimeout(function(){animateControl(ctrl,"hide")}, 100); } else { ctrl.style.setAttribute("display", "none"); } } }上班了,写得仓促些,有些地方楼主可以自己修正下,另外在渐近显示过程中控件中显示不全的内容是被hide还是scroll楼主也得自己加.如果需要layer显示的话还要注意select等控件不能被遮挡的问题. 希望能对楼主有所帮助
function animateControl(ctrl)
{
var curH = parseFloat(ctrl.style.height);
curH += 1;//自己控制下数值
if (curH < h)
{
setTimeout("animateControl("+ctrl+")",1000);
}
}
//基本原理就是这样,so easy
下面的具体些
function animateControl(ctrl,flag)//动画显示
{
if (!ctrl)
{
return;
}
if (!flag)
{
flag = "hide";
}
if (!ctrl.style.height)
{
ctrl.style.height = ctrl.offsetHeight;
}
if (!ctrl.style.top)
{
ctrl.style.top= getAbsolutePosition(ctrl).top;//如果你需要控件会移动的话
//就写个函数取控件的position吧.
}
var h = parseFloat(ctrl.style.height);
var y = parseFloat(ctrl.style.top);
if ("show" == flag)
{
h -= 5;
}
else if ("hide" == flag)
{
h += 5;
}
frame.style.setAttribute("height", y);
if ("show" == flag)
{
if (document.body.parentElement.offsetHeight - parseFloat(frame.style.height) < y)
{
window.setTimeout(function(){animatControl(ctrl,"show")}, 100);
}
}
else if ("hide" == flag)
{
if (h > 0)
{
window.setTimeout(function(){animateControl(ctrl,"hide")}, 100);
}
else
{
ctrl.style.setAttribute("display", "none");
}
}
}上班了,写得仓促些,有些地方楼主可以自己修正下,另外在渐近显示过程中控件中显示不全的内容是被hide还是scroll楼主也得自己加.如果需要layer显示的话还要注意select等控件不能被遮挡的问题.
希望能对楼主有所帮助