博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
消息到达提醒功能
阅读量:2797 次
发布时间:2019-05-13

本文共 1291 字,大约阅读时间需要 4 分钟。

当有新消息到达时,网页右下角探出一个小框框,提示消息,并指定链接过去。

实现:

div+css+ajax与js定时程序

div:

 

<div style="border:1px dashed #800000; padding:15px;display:none; position:fixed;width:160px;height:20px;background-color:#fdd2c5; font-size:19px;"

id="div_newMessage" name="div_newMessage"> </div>

js:

$(document).ready(function() {	checkNewMessage();	locateMessageDiv();	//去获取最新的私信	setInterval("checkNewMessage()",60000);	});

具体函数实现:

/** * 重定位DIV */function locateMessageDiv(){	//判断是否为IE6	if($.browser.msie && parseInt($.browser.version) <= 6){		$("#div_newMessage").css("position", "absolute");	}		$("#div_newMessage").css("bottom", 2);	$("#div_newMessage").css("right", 10);}//此处进行AJAX请求function checkNewMessage(){	  var url="/portal/pri/message/checkNewMessage.action?meetingId=${_portal_meeting_.id}";	  //alert(${_portal_meeting_.id});	  ajaxRequest(url,getNewMessage,false);	  function getNewMessage(data){		 var count=data.count;		  if(count>0){			  $("#div_newMessage").html("您有"+count+"条新的消息!");			  $("#div_newMessage").show();			//  $("#div_newMessage").toggle();		  }	  }}

涉及的功能:

1.JS定时程序:setInterval("checkNewMessage()",60000);

2.程序定位:既可以left top定位,也可以bottom right定位。左上优先原则。

3.IE6与其他大多数浏览器区别

如FF CHROME IE8下,当拖动滚动条的时候,position:fixed定位会一直在右下脚,但是position:absolute的时候,DIV会随着滚动条上去。

在IE6下 无论是fixed或者absolute都会跟着滚动条滚动。

转载地址:http://ynlmd.baihongyu.com/

你可能感兴趣的文章
poj 1703 Find them, Catch them(带权并查集)
查看>>
codeforces 479E E. Riding in a Lift(dp+段修改的优化)
查看>>
codeforces 351A A. Jeff and Rounding(智商题+枚举)
查看>>
codeforces 463D D. Gargari and Permutations(dp)
查看>>
codeforces 269B B. Greenhouse Effect(dp)
查看>>
codeforces 455B(博弈+dp)
查看>>
codeforces 375B B. Maximum Submatrix 2(dp)
查看>>
codeforces 294B B. Shaass and Bookshelf(dp)
查看>>
codeforces 505C C. Mr. Kitayuta, the Treasure Hunter (dp)
查看>>
codeforces 255C C. Almost Arithmetical Progression(dp)
查看>>
codeforces 219D D. Choosing Capital for Treeland(树形dp)
查看>>
codeforces 191A A. Dynasty Puzzles(dp)
查看>>
codeforces 201A A. Clear Symmetry(数论+构造)
查看>>
codeforces 461B B. Appleman and Tree(树形dp)
查看>>
DL Code Editor user manual
查看>>
codeforces 580D. Kefa and Dishes(状压dp)
查看>>
codeforces B. Cow Program (记忆化搜索)
查看>>
codeforces 478D D. Red-Green Towers(dp)
查看>>
codeforces 459E E. Pashmak and Graph(dp)
查看>>
codeforces 453B B. Little Pony and Harmony Chest(dp+数论)
查看>>