见如下代码:
//生成了随机秒数60-150之间
var num = Math.round(Math.random()*90+60);
alert(num);
//循环执行,每隔60-150秒钟执行一次showMsgIcon()
window.setInterval(showMsgIcon, 1000*num);
function showMsgIcon(){
$.getJSON("${ctx}/todoTask/getTodoTaskList.do?processed=0", function(result){
if(result.rows.length > 0){
var msgPicFadeOutIn = setInterval(function(){$("#msgPic").fadeOut(500).fadeIn(500);}, 1000);
$("#msgPic").attr("title", "您有待办任务、未读消息,点击查看");
$("#msgPic").click(function(){
if(msgPicFadeOutIn != ""){
clearInterval(msgPicFadeOutIn);
msgPicFadeOutIn = "";
}
$("#msgPic").fadeOut();
toAction("/todoTask/showMyUnProcessedTask.do", "我的待办任务", this);
});
}else{
$("#msgPic").fadeOut();
}
});
}