<script> <BR>/* <BR>By Auntion <BR>QQ 82874972 <BR>欢迎喜欢javascript 和 ajax的朋友++我QQ,大家共同进步,呵呵 <BR>使用方法 <BR>调用效果: Effect(1,2); <BR> 其中1为: 被改变对象的id <BR> 其中2为: 控制容器的id 可在使用: this.parentNode.id 取得(父标签的id) <BR>注意给对象ID的时候一定不要重复. <BR>*/ <BR>function $G(Read_Id) { return document.getElementById(Read_Id) } <BR>function Effect(ObjectId,parentId){ <BR> if ($G(ObjectId).style.display == 'none'){ <BR> Start(ObjectId,'Opens'); <BR> $G(parentId).innerHTML = "<a href=# onClick=javascript:Effect('"+ObjectId+"','"+parentId+"');>关闭" <BR> }else{ <BR> Start(ObjectId,'Close'); <BR> $G(parentId).innerHTML = "<a href=# onClick=javascript:Effect('"+ObjectId+"','"+parentId+"');>打开" <BR> } <BR>} <BR>function Start(ObjId,method){ <BR>var BoxHeight = $G(ObjId).offsetHeight; //获取对象高度 <BR>var MinHeight = 5; //定义对象最小高度 <BR>var MaxHeight = 130; //定义对象最大高度 <BR>var BoxAddMax = 1; //递增量初始值 <BR>var Every_Add = 0.15; //每次的递(减)增量 [数值越大速度越快] <BR>var Reduce = (BoxAddMax - Every_Add); <BR>var Add = (BoxAddMax + Every_Add); <BR>if (method == "Close"){ <BR>var Alter_Close = function(){ //构建一个虚拟的[递减]循环 <BR> BoxAddMax /= Reduce; <BR> BoxHeight -= BoxAddMax; <BR> if (BoxHeight <= MinHeight){ <BR> $G(ObjId).style.display = "none"; <BR> window.clearInterval(BoxAction); <BR> } <BR> else $G(ObjId).style.height = BoxHeight; <BR>} <BR>var BoxAction = window.setInterval(Alter_Close,1); <BR>} <BR>else if (method == "Opens"){ <BR>var Alter_Opens = function(){ //构建一个虚拟的[递增]循环 <BR> BoxAddMax *= Add; <BR> BoxHeight += BoxAddMax; <BR> if (BoxHeight >= MaxHeight){ <BR> $G(ObjId).style.height = MaxHeight; <BR> window.clearInterval(BoxAction); <BR> }else{ <BR> $G(ObjId).style.display= "block"; <BR> $G(ObjId).style.height = BoxHeight; <BR> } <BR>} <BR>var BoxAction = window.setInterval(Alter_Opens,1); <BR>} <BR>} <BR></script>