我已经使用此函数从web.config文件中获取session timeout
。
function readwebconfig() {
var sessiontime = "<%= Session.Timeout %>";
document.getElementById('lblmsg').innerHTML = sessiontime;
}
它返回一些数值,现在我希望使用javascript decrement
这个值。并显示此值,如9Min :30Sec's.
提前致谢。
答案 0 :(得分:1)
<强> JS: - 强>
var sessionTimeout = <%= Session.Timeout %> ;
var now = new Date();
var kickoff = now.setMinutes(now.getMinutes() + parseInt(sessionTimeout));
function updateWCTime() {
now = new Date();
diff = kickoff - now;
days = Math.floor(diff / (1000 * 60 * 60 * 24));
hours = Math.floor(diff / (1000 * 60 * 60));
mins = Math.floor(diff / (1000 * 60));
secs = Math.floor(diff / 1000);
mm = mins - hours * 60;
ss = secs - mins * 60;
document.getElementById("txt")
.innerHTML = mm + ' minutes ' + ss + ' seconds';
}
setInterval(updateWCTime, 1000);
<强> HTML: - 强>
<div id="txt">
</div>