日期:2014-05-18 浏览次数:20640 次
window.onresize = resizeDiv; //根据窗体高度和宽度,改变短消息提示框的高度和宽度 window.onerror = function(){} //出现错误时,不做任何处理 var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;//关于位置的相关变量 function $int(num){try{return parseInt(num);}catch(ex){return 0;}} function viewMsg() { try{ var divElement = $(divName); divTop = $int(divElement.style.top) //div的x坐标 divLeft = $int(divElement.style.left) //div的y坐标 divHeight = $int(divElement.offsetHeight)//div的高度 divWidth = $int(divElement.offsetWidth) //div的宽度 docWidth = document.documentElement.clientWidth; //窗体宽度 docHeight = document.documentElement.clientHeight; //窗体高度 divElement.style.top = docHeight + 10;//设置div的Y坐标 divElement.style.left = docWidth - divWidth//设置div的X坐标 divElement.style.visibility="visible" //设置div显示 objTimer = window.setInterval("moveDiv()",10) //设置定时器 }catch(e){alert("viewMsg"+e.description);} } function resizeDiv(){ i+=1 if (i>500) closeDiv() try{ var divElement = $(divName); divHeight = $int(divElement.offsetHeight) //设置div高度 divWidth = $int(divElement.offsetWidth) //设置div宽度 docWidth = document.documentElement.clientWidth; //获取窗体宽度 docHeight = document.documentElement.clientHeight; //设置窗体高度 divElement.style.top = docHeight - divHeight;// + $int(document.body.scrollTop)//设置div的y坐标 divElement.style.left = docWidth - divWidth;// + $int(document.body.scrollLeft)//设置div的x坐标 }catch(e){alert("resizeDiv"+e.description);} } function moveDiv(){ try{ var divElement = $(divName); if ($int(divElement.style.top) <= (docHeight - divHeight)){ window.clearInterval(objTimer) objTimer = window.setInterval("resizeDiv()",1) //调整div的位置和大小 } divTop = $int(divElement.style.top)//获取y坐标 divElement.style.top = divTop - 1//调整div的Y坐标 } catch(e){alert("moveDiv"+e.description);} } function closeDiv(){ var divElement = $(divName); divElement.style.visibility='hidden';//将短信息提示层隐藏 if(objTimer) window.clearInterval(objTimer); //清除定时器 }
------解决方案--------------------
前台:
<input type="hidden" onclick="viewMsg()" runat="server" id="hidMsg" value="0" /> <div id="divMsg" style="border-right: #455690 1px solid; border-top: #a6b4cf 1px solid; z-index: 99999; left: 0px; visibility: hidden; border-left: #a6b4cf 1px solid; width: 180px; border-bottom: #455690 1px solid; position: absolute; top: 0px; height: 116px; background-color: #c9d3f3"> <table style="border-top: #ffffff 1px solid; border-left: #ffffff 1px solid" cellspacing="0" cellpadding="0" width="100%" bgcolor="#cfdef4" border="0"> <tbody> <tr> <td style="font-size: 12px; color: #0f2c8c" width="30" height="24"> </td> <td style="font-weight: normal; font-size: 12px; color: #1f336b; padding-top: 4px; padding-left: 4px" valign="center" width="100%"> Mac审批提示:</td>