时间:13-06-17 栏目:Javascript 作者:zongyan86 评论:0 点击: 3,274 次
本文标签: Jquery EasyUI web前端开发
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="E_PopTip.ascx.cs" Inherits="Control_E_PopTip" %> <script language="JavaScript"> //写cookies函数 function SetCookie(name,value)//两个参数,一个是cookie的名子,一个是值 { var Days = 1; //此 cookie 将被保存 30 天 var exp = new Date(); //new Date("December 31, 9998"); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); } function getCookie(name)//取cookies函数 { var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return null; } function delCookie(name)//删除cookie { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval=getCookie(name); if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString(); } function trim(str){ //删除左右两端的空格 return str.replace(/(^\s*)|(\s*$)/g, ""); } if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } req.open("get", "PopTip.aspx?act=sendmsg&t=" + Math.random()); req.onreadystatechange=RequestCallBack; req.send(); function RequestCallBack(){ if (req.readyState == 4) { if (req.status == 200) { var check_num=trim(req.responseText); if(check_num!="") { if(getCookie("check_num")==check_num) { window.setInterval("getMsg()", 1800000); } else { getMsg(); SetCookie("check_num",check_num); } } } } } var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0; function getMsg() { try{ divTop = parseInt(document.getElementById("eMeng").style.top,10) divLeft = parseInt(document.getElementById("eMeng").style.left,10) divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10) divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10) docWidth = document.documentElement.clientWidth; docHeight = document.documentElement.clientHeight; document.getElementById("eMeng").style.top =( parseInt(document.documentElement.scrollTop,10) + docHeight + 10)+"px";// divHeight document.getElementById("eMeng").style.left =( parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth )+"px"; document.getElementById("eMeng").style.visibility="visible" objTimer = window.setInterval("moveDiv()",10) } catch(e){} } function resizeDiv() { i+=1 if(i>1200) closeDiv() //想不用自动消失由用户来自己关闭所以屏蔽这句 try{ divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10) divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10) docWidth = document.documentElement.clientWidth; docHeight = document.documentElement.clientHeight; document.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10) document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10) } catch(e){} } function moveDiv() { try { if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(document.documentElement.scrollTop,10))) { window.clearInterval(objTimer) objTimer = window.setInterval("resizeDiv()",1) } divTop = parseInt(document.getElementById("eMeng").style.top,10) document.getElementById("eMeng").style.top = (divTop - 1 )+"px"; } catch(e){} } function closeDiv() { document.getElementById('eMeng').style.visibility='hidden'; if(objTimer) window.clearInterval(objTimer) } </script> <DIV id=eMeng style="BORDER: #a6b4cf 1px solid; Z-INDEX:99999; LEFT: 0px; VISIBILITY: hidden; WIDTH: 200px; POSITION: absolute; TOP: 0px; HEIGHT: 150px; BACKGROUND-COLOR: #c9d3f3"> <TABLE style="BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid;height:150px;" cellSpacing=0 cellPadding=0 width="100%" bgColor=#cfdef4 border=0> <TBODY> <TR> <TD style="FONT-SIZE: 12px; BACKGROUND-IMAGE: url(msgTopBg.gif); COLOR: #0f2c8c" width=30 height=24></TD> <TD style="FONT-WEIGHT: normal; FONT-SIZE: 12px; BACKGROUND-IMAGE: url(msgTopBg.gif); COLOR: #1f336b; PADDING-TOP: 4px;PADDING-left: 4px;" vAlign=center width="100%"> 消息提示:</TD> <TD style="BACKGROUND-IMAGE: url(msgTopBg.gif); PADDING-TOP: 2px;PADDING-right:2px" vAlign=center align=right width=19><span title=关闭 style="CURSOR: hand;color:red;font-size:12px;font-weight:bold;margin-right:4px;" onclick=closeDiv() >×</span></TD> </TR> <TR> <TD style="PADDING-RIGHT: 1px; BACKGROUND-IMAGE: url(1msgBottomBg.jpg); PADDING-BOTTOM: 1px" colSpan=3 height=102> <DIV style="BORDER-RIGHT: #b9c9ef 1px solid;BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 1px; FONT-SIZE: 12px; PADDING-BOTTOM: 10px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 10px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%"> <DIV align=left style="word-break:break-all"><%=show_Msg() %></DIV> </DIV> </TD> </TR> </TBODY> </TABLE> </DIV>