easyUI实现(alert)提示框自动关闭

来源:互联网 发布:mac http 抓包工具 编辑:程序博客网 时间:2024/05/16 13:59
原理:使用js的定时任务函数setInterval设置时间,然后触发关闭事件
参数说明
title:提示框的标题
msg:提示信息内容
ico:显示的提示信息图标,'info','warnning','error'等
函数体
function alert_autoClose(title,msg,icon){ 
 var interval;  
 var time=1000;  
 var x=2;   //设置时间2s
$.messager.alert(title,msg,icon,function(){}); 
 interval=setInterval(fun,time); 
       function fun(){  
     --x;  
     if(x==0){ 
        clearInterval(interval); 
  $(".messager-body").window('close');   
      }  
}; 
}
来源http://blog.sina.com.cn/s/blog_681b1dbf0102w7o0.html