js右下角消息弹窗效果可以快速的让用户注意到网站系统提示的消息,由于是右下角显示的js弹窗消息,所以既美观,又不占位置,用户会习惯性的查看右边的信息,效果非常明显,下面我们来看看这两种js特效吧,是本人专门收藏的。
效果1:类似于qq消息效果,js兼容性很强,适合任何平台。

js代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script typet="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<title>右下角的弹窗,sky整理收集</title>
</head>
<style type="text/css">
#winpop { width:220px; height:0px; position:absolute; right:0; bottom:0; border:1px solid #999999; margin:0; padding:1px; overflow:hidden; display:none; background:#FFFFFF}
#winpop #title {
width:100%; height:20px; line-height:20px;
font-weight:bold; text-align:center; font-size:12px;
FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#54C4F2,endColorStr=#D1F2F9); /*IE*/
background:-moz-linear-gradient(top,#54C4F2,#D1F2F9);/*火狐*/
background:-webkit-gradient(linear, 0% 0%, 0% 100%,from(#54C4F2), to(#D1F2F9));/*谷歌*/
background-image: -webkit-gradient(linear,left bottom,left top,color-start(0, #54C4F2),color-stop(1, #D1F2F9));/* Safari & Chrome*/
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#54C4F2', endColorstr='#D1F2F9'); /*IE6 & IE7*/
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#54C4F2', endColorstr='#D1F2F9')"; /* IE8 */
background: -ms-linear-gradient(left,#D1F2F9 0%,#54C4F2 100%);
}
#winpop #msg{display:block; margin-top:30px; padding:0; text-align:center;}
#winpop #msg li{display:block;list-style:none; font-weight:bold; font-size:12px; padding:0}
#winpop #msg li a{display:block;text-decoration:none; color:#2D82FF;}
#winpop #msg li a:hover{text-decoration:underline;color:red;}
.close { position:absolute; right:10px; top:1px; color:#5A5A5A; cursor:pointer;}
</style>
<script type="text/javascript">
function tips_pop(){
var MsgPop=document.getElementById("winpop");//获取窗口这个对象,即ID为winpop的对象
var popH=parseInt(MsgPop.style.height);//用parseInt将对象的高度转化为数字,以方便下面比较
if (popH==0){ //如果窗口的高度是0
MsgPop.style.display="block";//那么将隐藏的窗口显示出来
show=setInterval("changeH('up')",2);//开始以每0.002秒调用函数changeH("up"),即每0.002秒向上移动一次
}
else { //否则
hide=setInterval("changeH('down')",2);//开始以每0.002秒调用函数changeH("down"),即每0.002秒向下移动一次
}
}
function changeH(str) {
var MsgPop=document.getElementById("winpop");
var popH=parseInt(MsgPop.style.height);
if(str=="up"){ //如果这个参数是UP
if (popH<=100){ //如果转化为数值的高度小于等于100
MsgPop.style.height=(popH+4).toString()+"px";//高度增加4个象素
}
else{
clearInterval(show);//否则就取消这个函数调用,意思就是如果高度超过100象度了,就不再增长了
}
}
if(str=="down"){
if (popH>=4){ //如果这个参数是down
MsgPop.style.height=(popH-4).toString()+"px";//那么窗口的高度减少4个象素
}
else{ //否则
clearInterval(hide); //否则就取消这个函数调用,意思就是如果高度小于4个象度的时候,就不再减了
MsgPop.style.display="none"; //因为窗口有边框,所以还是可以看见1~2象素没缩进去,这时候就把DIV隐藏掉
}
}
}
window.onload=function(){ //加载
document.getElementById('winpop').style.height='0px';//我不知道为什么要初始化这个高度,CSS里不是已经初始化了吗,知道的告诉我一下
setTimeout("tips_pop()",800); //0.8秒后调用tips_pop()这个函数
}
</script>
<body>
<div id="winpop">
<div id="title"><div id="titlename">您有(请假流程)2条需要审批</div><span class="close" onclick="closemsg()">X</span></div>
<ul id="msg">
<li><a href="#">请假审批流程(1)<a/></li>
</ul>
</div>
</body>
<script>
function closemsg(){
document.getElementById('winpop').style.height='0px';
document.getElementById('titlename').innerText = 'Fred Flinstone';
tips_pop();
}
</script>
</html>效果2:类似于网易新闻,也是非常美观的js效果特效。

js代码如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>右下角浮动窗口</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<style type="text/css">
#msg_win{
position:absolute;
right:0px;
overflow:hidden;
z-index:99;
border:1px solid #1087B8;
background:#EEEEEE;
width:240px;
font-size:12px;
margin:0px;
display:block;
top:503px;
visibility:visible;
opacity:1;
}
#msg_win .icos{
position:absolute;
top:2px;
right:2px;
z-index:9;
}
.icos a{
float:left;
color:#FFFFFF;
margin:1px;
text-align:center;
font-weight:bold;
width:14px;
height:22px;
line-height:22px;
padding:1px;
text-decoration:none;
font-family:webdings;
}
.icos a:hover{
color:#FFCC00;
}
#msg_title{
background:#54C4F2;
border-bottom:1px solid #1087B8;
border-top:1px solid #FFF;
border-left:1px solid #FFF;
color:#FFFFFF;
height:25px;
line-height:25px;
text-indent:5px;
font-weight:bold;
}
#msg_content{
margin:5px;
margin-right:0;
width:230px;
height:126px;
overflow:hidden;
}
</style>
</head>
<body>
<div style="height:2000px;"></div>
<div id="msg_win" >
<div class="icos">
<a id="msg_min" title="最小化" href="javascript:void 0">_</a><a id="msg_close" title="关闭" href="javascript:void 0">×</a>
</div>
<div id="msg_title">浮动窗口标题:</div>
<div id="msg_content">浮动窗口内容:欢迎提出宝贵意见,谢谢!</div>
</div>
<script language="javascript">
var Message={
set: function() {//最小化与恢复状态切换
var set=this.minbtn.status == 1?[0,1,'block',this.char[0],'最小化']:[1,0,'none',this.char[1],'恢复'];
this.minbtn.status=set[0];
this.win.style.borderBottomWidth=set[1];
this.content.style.display =set[2];
this.minbtn.innerHTML =set[3];
this.minbtn.title = set[4];
this.win.style.top = this.getY().top;
},
close: function() {//关闭
this.win.style.display = 'none';
window.onscroll = null;
},
setOpacity: function(x) {//设置透明度
var v = x >= 100 ? '': 'Alpha(opacity=' + x + ')';
this.win.style.visibility = x<=0?'hidden':'visible';//IE有绝对或相对定位内容不随父透明度变化的bug
this.win.style.filter = v;
this.win.style.opacity = x / 100;
},
show: function() {//渐显
clearInterval(this.timer2);
var me = this,fx = this.fx(0, 100, 0.1),t = 0;
this.timer2 = setInterval(function() {
t = fx();
me.setOpacity(t[0]);
if (t[1] == 0) {
clearInterval(me.timer2)
}
},6);//10 to 6
},
fx: function(a, b, c) {//缓冲计算
var cMath = Math[(a - b) > 0 ? "floor": "ceil"],c = c || 0.1;
return function() {
return [a += cMath((b - a) * c), a - b]
}
},
getY: function() {//计算移动坐标
var d = document,b = document.body, e = document.documentElement;
var s = Math.max(b.scrollTop, e.scrollTop);
var h = /BackCompat/i.test(document.compatMode)?b.clientHeight:e.clientHeight;
var h2 = this.win.offsetHeight;
return {foot: s + h + h2 + 2+'px',top: s + h - h2 - 2+'px'}
},
moveTo: function(y) {//移动动画
clearInterval(this.timer);
var me = this,a = parseInt(this.win.style.top)||0;
var fx = this.fx(a, parseInt(y));
var t = 0 ;
this.timer = setInterval(function() {
t = fx();
me.win.style.top = t[0]+'px';
if (t[1] == 0) {
clearInterval(me.timer);
me.bind();
}
},6);//10 to 6
},
bind:function (){//绑定窗口滚动条与大小变化事件
var me=this,st,rt;
window.onscroll = function() {
clearTimeout(st);
clearTimeout(me.timer2);
me.setOpacity(0);
st = setTimeout(function() {
me.win.style.top = me.getY().top;
me.show();
},100);//600 mod 100
};
window.onresize = function (){
clearTimeout(rt);
rt = setTimeout(function() {me.win.style.top = me.getY().top},100);
}
},
init: function() {//创建HTML
function $(id) {return document.getElementById(id)};
this.win=$('msg_win');
var set={minbtn: 'msg_min',closebtn: 'msg_close',title: 'msg_title',content: 'msg_content'};
for (var Id in set) {this[Id] = $(set[Id])};
var me = this;
this.minbtn.onclick = function() {me.set();this.blur()};
this.closebtn.onclick = function() {me.close()};
this.char=navigator.userAgent.toLowerCase().indexOf('firefox')+1?['_','::','×']:['0','2','r'];//FF不支持webdings字体
this.minbtn.innerHTML=this.char[0];
this.closebtn.innerHTML=this.char[2];
setTimeout(function() {//初始化最先位置
me.win.style.display = 'block';
me.win.style.top = me.getY().foot;
me.moveTo(me.getY().top);
},0);
return this;
}
};
Message.init();
</SCRIPT>
</body>
</html>各位开发者可以对以上js代码进行修改,以适应自己的项目。