js右下弹出窗口代码加定时

javascript代码:

// JavaScript Document
var url_xinxi=getxinxi.php; //获取窗口显示内容的URL;
function tips_pop(){
var MsgPop=document.getElementById("winpop");
var popH=parseInt(MsgPop.style.height);//将对象的高度转化为数字
if (popH==0){
MsgPop.style.display="block";//显示隐藏的窗口
$.getJSON(url_xinxi, { name: "John", time: "2pm" },
function(data){
if(data.status=='sccess'){
$("#winpop").html(data.msg);
show=setInterval("changeH('up')",50);
}
});
}
else {
hide=setInterval("changeH('down')",50);
}
}
function changeH(str) {
var MsgPop=document.getElementById("winpop");
var popH=parseInt(MsgPop.style.height);
if(str=="up"){
if (popH<=140){
MsgPop.style.height=(popH+4).toString()+"px";
var topHeight2 = document.documentElement.scrollTop + document.documentElement.clientHeight - popH-4;
$("#winpop").css("top",topHeight2+"px");
}
else{
clearInterval(show);
}
}
if(str=="down"){
if (popH>=4){
MsgPop.style.height=(popH-4).toString()+"px";
}
else{
clearInterval(hide);
MsgPop.style.display="none"; //隐藏DIV
}
}
}
function tips_pop2(str) {
document.getElementById('winpop').style.height='0px';
document.getElementById('winpop').style.display="none";
tips_pop();
setTimeout("tips_pop2()",60000);
}
$(document).ready(function(){
if($("#winpop").length>0){
//第一次加载执行
window.onload=function(){//加载
document.getElementById('winpop').style.height='0px';
setTimeout("tips_pop()",3000);//3秒后调用tips_pop()这个函数
}
//每一分钟执行
$(function () {
setTimeout("tips_pop2()",60000);
});
//滚动条
$(window).scroll( function() {
var MsgPop=document.getElementById("winpop");
var popH=parseInt(MsgPop.style.height);//将对象的高度转化为数字
var topHeight = document.documentElement.scrollTop + document.documentElement.clientHeight - popH;
$("#winpop").css("top",topHeight+"px");
});
}
});

html代码:


<html>
<style>
/*右下信息提示*/
#winpop { width:264px; height:0px;position:absolute; right:0; bottom:0; border:1px solid #66CC33; margin:0; padding:0px; overflow:hidden; display:none;}
#winpop .title { width:100%; height:28px; line-height:28px; background:#66CC33;text-align:left; font-size:12px; color:#ffffff;padding-left:10px; background:url(../../images/icon/yx_title.gif);}
#winpop .con { width:260; min-height:110px;line-height:20px; padding:10px; text-align:left; font-size:12px; color:#000000; text-decoration:none; background:#FFFFFF; overflow:hidden; }
#silu { font-size:12px; color:#666; position:absolute; right:0; text-align:right; text-decoration:underline; line-height:22px;}
.close { position:absolute; right:4px; top:-1px; color:#FFF; cursor:pointer}
</style>
<body>
<!--弹出窗-->
<div id="winpop">
</div>
<!--end-->
</body>
</html>

说明:
定义和用法
setInterval() 方法可按照指定的周期(以毫秒计)来调用函数或计算表达式。   setInterval() 方法会不停地调用函数,直到 clearInterval() 被调用或窗口被关闭。由 setInterval() 返回的 ID 值可用作 clearInterval() 方法的参数。
语法
setInterval(code,millisec[,"lang"])   
参数 描述
code 必需。要调用的函数或要执行的代码串。
millisec 必需。周期性执行或调用 code 之间的时间间隔,以毫秒计。
返回值
一个可以传递给 Window.clearInterval() 从而取消对 code 的周期性执行的值。
setTimeout() 只执行 code 一次。如果要多次调用,请使用 setInterval() 或者让 code 自身再次调用 setTimeout()。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值