1.等待所有图片加载
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
var imgObjs = [],
count = 0; rotate.prizeTotal = prizes.length; //图片总数
var timer = setInterval(function() {
if (count == rotate.prizeTotal ) {
clearInterval(timer);
//加载后执行的回调函数
}
}, 50); for ( var i = 0;i < prizes.length; i++){
var img = new Image();
img.src = prizes[i].prize_icon; //prizes数组的prize_icon存放图片的地址
imgObjs.push(img);
img.onload = function(){
count++;
}
} |
2.js获取服务器时间
1
2
3
|
var timstamp = new Date().valueOf();
var systemTime = new Date($.ajax({url: "?t=" +timstamp,async: false }).getResponseHeader( "Date" ));
return systemTime.valueOf();
|
3.获取当前时间yyyymmdd格式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
//获取当前时间yyyymmdd格式 var CurrentDate = "" ;
var day = new Date();
var Year = day.getFullYear();
var Month = day.getMonth()+1;
var Day = day.getDate();
CurrentDate += Year; if (Month >= 10 ){
CurrentDate += Month;
} else {
CurrentDate += "0" + Month;
} if (Day >= 10 ){
CurrentDate += Day ;
} else {
CurrentDate += "0" + Day ;
} |