8 个解决方案
#1
var timer = setInterval(Refresh, "1000");1000=1秒
var timer = setInterval(chenck, "500");
function Refresh(){
前台页面刷新时间
}
在refresh里面谢你要干的事情
function chenck(){
ajax后台验证,根据结果来决定是否满足条件,来关闭刷新时间的interval
}
var timer = setInterval(chenck, "500");
function Refresh(){
前台页面刷新时间
}
在refresh里面谢你要干的事情
function chenck(){
ajax后台验证,根据结果来决定是否满足条件,来关闭刷新时间的interval
}
#2
页面不能刷新 这不就会ajax么
#3
是啊,用ajax到后台轮询,看看条件是否达到啊,ajax用了好像不刷新页面吧,大哥
#4
▲ 倒计时
<script>
//倒计时
function ShowOverTime(tts) {
var nowtime = new Date();
var overtime = StringtoDate(tts);
nowtime -= 1000;
var days = (overtime - nowtime) / 1000 / 60 / 60 / 24;
var dayNum = Math.floor(days);
var hours = (overtime - nowtime) / 1000 / 60 / 60 - (24 * dayNum);
var houNum = Math.floor(hours);
if (houNum < 10) { houNum = "0" + houNum; }
var minutes = (overtime - nowtime) / 1000 / 60 - (24 * 60 * dayNum) - (60 * houNum);
var minNum = Math.floor(minutes);
if (minNum < 10) { minNum = "0" + minNum; }
var seconds = (overtime - nowtime) / 1000 - (24 * 60 * 60 * dayNum) - (60 * 60 * houNum) - (60 * minNum);
var secNum = Math.floor(seconds);
if (secNum < 10) { secNum = "0" + secNum; }
var result = "<b>" + dayNum + "</b>天<b>" + houNum + "</b>小时<b>" + minNum + "</b>分<b>" + secNum + "</b>秒";
if (dayNum > 0) {
$("[id$='timetitle']").html(result);
} else {
$("[id$='timetitle']").html("已经下架");
}
}
▲解决JS new Date(xx) NaN
//时间转换
function StringtoDate(getTemp) {
temp = getTemp.split(" ");
var dateReturn = temp[0].split("-")[1] + "/" + temp[0].split("-")[2] + "/" + temp[0].split("-")[0] + " "
+ temp[1].split(":")[0] + ":" + temp[1].split(":")[1] + ":" + temp[1].split(":")[2];
return Date.parse(dateReturn);
}
</script>
<p class="t1">剩余时间 :
<span id="timetitle">请稍等,载入时间....</span>
<script>setInterval('ShowOverTime(\"<%#Eval("overtime")%>\")', 1000);</script>
</p>
每次请求时后台 IsPostBack做逻辑判断,或者倒计时为0时走ajax处理
#5
ajax最大的特点就是局部刷新吧!
#6
前台 用 js 的 setTimeout 或者 setInterval 函数
#7
ajax加js的settimeout或setinterval
#8
看样是解决了,来蹭个分吧
#1
var timer = setInterval(Refresh, "1000");1000=1秒
var timer = setInterval(chenck, "500");
function Refresh(){
前台页面刷新时间
}
在refresh里面谢你要干的事情
function chenck(){
ajax后台验证,根据结果来决定是否满足条件,来关闭刷新时间的interval
}
var timer = setInterval(chenck, "500");
function Refresh(){
前台页面刷新时间
}
在refresh里面谢你要干的事情
function chenck(){
ajax后台验证,根据结果来决定是否满足条件,来关闭刷新时间的interval
}
#2
页面不能刷新 这不就会ajax么
#3
是啊,用ajax到后台轮询,看看条件是否达到啊,ajax用了好像不刷新页面吧,大哥
#4
▲ 倒计时
<script>
//倒计时
function ShowOverTime(tts) {
var nowtime = new Date();
var overtime = StringtoDate(tts);
nowtime -= 1000;
var days = (overtime - nowtime) / 1000 / 60 / 60 / 24;
var dayNum = Math.floor(days);
var hours = (overtime - nowtime) / 1000 / 60 / 60 - (24 * dayNum);
var houNum = Math.floor(hours);
if (houNum < 10) { houNum = "0" + houNum; }
var minutes = (overtime - nowtime) / 1000 / 60 - (24 * 60 * dayNum) - (60 * houNum);
var minNum = Math.floor(minutes);
if (minNum < 10) { minNum = "0" + minNum; }
var seconds = (overtime - nowtime) / 1000 - (24 * 60 * 60 * dayNum) - (60 * 60 * houNum) - (60 * minNum);
var secNum = Math.floor(seconds);
if (secNum < 10) { secNum = "0" + secNum; }
var result = "<b>" + dayNum + "</b>天<b>" + houNum + "</b>小时<b>" + minNum + "</b>分<b>" + secNum + "</b>秒";
if (dayNum > 0) {
$("[id$='timetitle']").html(result);
} else {
$("[id$='timetitle']").html("已经下架");
}
}
▲解决JS new Date(xx) NaN
//时间转换
function StringtoDate(getTemp) {
temp = getTemp.split(" ");
var dateReturn = temp[0].split("-")[1] + "/" + temp[0].split("-")[2] + "/" + temp[0].split("-")[0] + " "
+ temp[1].split(":")[0] + ":" + temp[1].split(":")[1] + ":" + temp[1].split(":")[2];
return Date.parse(dateReturn);
}
</script>
<p class="t1">剩余时间 :
<span id="timetitle">请稍等,载入时间....</span>
<script>setInterval('ShowOverTime(\"<%#Eval("overtime")%>\")', 1000);</script>
</p>
每次请求时后台 IsPostBack做逻辑判断,或者倒计时为0时走ajax处理
#5
ajax最大的特点就是局部刷新吧!
#6
前台 用 js 的 setTimeout 或者 setInterval 函数
#7
ajax加js的settimeout或setinterval
#8
看样是解决了,来蹭个分吧