var time_now_server, time_now_client, time_end, time_server_client, timerID,types;
window.onload = function() {
time_end = new Date('$FunctionLabel.FormatDateTime($!{drMeetingError.StartDateTime})'.replace("-", "/")); //结束的时间
time_end = time_end.getTime();
alert(time_end);
time_now_server = new Date('$FunctionLabel.CurrentDate'.replace("-", "/")); //开始的时间
time_now_server = time_now_server.getTime();
time_now_client = new Date();
time_now_client = time_now_client.getTime();
time_server_client = time_now_server - time_now_client;
setTimeout("show_time()", 1000);
types = getQueryString("type");
}
function show_time() {
var timer = document.getElementById("timer");
if (!timer) {
return;
}
var time_now, time_distance, str_time;
var int_day, int_hour, int_minute, int_second;
var time_now = new Date();
time_now = time_now.getTime() + time_server_client;
time_distance = time_end - time_now;
if (parseInt(time_distance) > 0) {
alert(1);
int_day = Math.floor(time_distance / 86400000)
time_distance -= int_day * 86400000;
int_hour = Math.floor(time_distance / 3600000)
time_distance -= int_hour * 3600000;
int_minute = Math.floor(time_distance / 60000)
time_distance -= int_minute * 60000;
int_second = Math.floor(time_distance / 1000)
alert(2);
if (int_day == 0 && int_hour == 0 && (int_minute * 60 + int_second) <= 1200 && types==1) {
GetTrainUrl();
}
if (int_hour < 10) {
int_hour = "0" + int_hour;
}
if (int_minute < 10) {
int_minute = "0" + int_minute;
}
if (int_second < 10) {
int_second = "0" + int_second;
}
alert(3);
str_time = " 距离直播还有:" +
" " + int_day + " 天" +
" " + int_hour + " 小时" +
" " + int_minute + " 分" +
" " + int_second + " 秒";
timer.innerHTML = str_time;
setTimeout("show_time()", 1000);
}
else {
clearTimeout(timerID);
timer.style.display = "none";
}
}
经测试,IE下的
time_end = time_end.getTime(); new Date似乎火狐都不兼容。。。求兼容
JS 火狐与IE下时间格式转化问题,IE下正常,火狐不兼容。。求大神。。在线等
答案:2 悬赏:40 手机版
解决时间 2021-02-07 11:40
- 提问者网友:不爱我么
- 2021-02-06 23:19
最佳答案
- 五星知识达人网友:何以畏孤独
- 2021-02-07 00:35
new Date() 是全兼容的。
参数不要有中文
参数不要有中文
全部回答
- 1楼网友:酒者煙囻
- 2021-02-07 01:23
你好!
恩 你后来是加上了 /g 替换掉了 所有的 - 是吧。。
我的回答你还满意吗~~
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯