/* $id: showdiv.js 15469 2008-12-19 06:34:44z testyang $ */ //创建显示层 var swtemp = 0; var timer = null; //显示层 function showdiv(obj) { var inputid = obj.id; if (swtemp == 1) { hidediv("messagediv"); } if (!getobj("messagediv")) { //若尚未创建就创建层 crertdiv("" , "div" , "messagediv" , "messagediv");//创建层"messagediv" crertdiv("messagediv" , "li" , "messageli" , "messageli");//创建"请刷新"li getobj("messageli").innerhtml = show_div_text; crertdiv("messagediv" , "a" , "messagea" , "");//创建"关闭"a getobj("messagea").innerhtml = show_div_exit; getobj("messagea").onclick = function(){hidediv("messagediv");}; } var newdiv = getobj("messagediv"); newdiv.style.left = (getabsoluteleft(obj) - 50) + "px"; newdiv.style.top = (getabsolutetop(obj) - 65) + "px"; newdiv.style.display = "block"; timer = settimeout(function(){hidediv("messagediv");} , 3000); swtemp = 1; } //创建层 function crertdiv(parent , element , id , css) { var newobj = document.createelement(element); if(id && id != "") { newobj.id = id; } if(css && css != "") { newobj.classname = css; } if(parent && parent!="") { var theobj = getobj(parent); var parent = theobj.parentnode; if(parent.lastchild == theobj) { theobj.appendchild(newobj); } else { theobj.insertbefore(newobj, theobj.nextsibling); } } else { document.body.appendchild(newobj); } } //隐藏层 function hidediv(objid) { getobj(objid).style.display = "none"; swtemp = 0; cleartimeout(timer); } //获取对象 function getobj(obj) { return document.getelementbyid(obj); } function getabsoluteheight(obj) { return obj.offsetheight; } function getabsolutewidth(obj) { return obj.offsetwidth; } function getabsoluteleft(obj) { var s_el = 0; var el = obj; while(el) { s_el = s_el + el.offsetleft; el = el.offsetparent; } return s_el; } function getabsolutetop(obj) { var s_el = 0; var el = obj; while(el) { s_el = s_el + el.offsettop; el = el.offsetparent; } return s_el; }