java脚本在asp.net 3.5中倒数计时器 [英] java script Count Down Timer in asp.net 3.5
问题描述
您好的专业人士
在我的项目中有条件,我需要通过客户端登录,登录后我必须给他一个小时的可访问性我的网站策略时间将是登录时间,它将存储在数据库中,我只需要从数据库获取登录时间并显示该时间的计数器,一小时后只需要做Response.Redirect(" MyPage.aspx") 。
我必须通过Java脚本执行此操作的主要内容,我是JS中的新手,尝试了许多代码,但没有得到实际结果....... .can any帮助我
hi professsionals
there is conditon in my project where i need to do login by client and after login i have to give him only one hour time for accessbility of my site strat time will be login time and it will store in Database i need to do only that take login time from DB and show counter with that time and after one hour need to do only Response.Redirect("MyPage.aspx").
the main thing that i have to do this by Java script and i am new in JS try many codes but not getting actually result........can any onje help me
推荐答案
检查以下代码。
Check the below code.
//After you login, put the time (i.e. in minutes from database) in to a hidden feild from server side.
var sessionTimeout = "2"; // Put the value of that hidden feild in to this variable
var globalmins = 1; // Substract one minutes from the hidden feild and put it in to this variable
var timeOnPageLoad = new Date();
var redirectToWelcomePageTimer = null;
//To redirect to the welcome page
var redirectToWelcomePageTimer = setTimeout('RedirectToWelcomePage()', parseInt(sessionTimeout, 10) * 60 * 1000);
var milisec = 0
var seconds = 60
var minutes = globalmins;
function display() {
if (minutes + ":" + seconds == "0.1") {
}
else {
if (milisec <= 0) {
milisec = 10
seconds -= 1
}
if (seconds <= 0) {
milisec = 0
seconds = 60
minutes -= 1
}
if (minutes <= -1) {
milisec = 0
seconds = 0
}
else
milisec -= 1
}
var timestring = "Your session will expire in " + minutes + ":" + seconds + " Minutes"
(' #showtimeleft')。html(timestring);
setTimeout( display();, 100 )
}
display();
// 会话超时
函数RedirectToWelcomePage(){
window.alert( 会话已过期。您将被重定向到某个页面);
window.location = Default.aspx;
}
('#showtimeleft').html(timestring); setTimeout("display();", 100) } display(); //Session timeout function RedirectToWelcomePage() { window.alert("Session expired. You will be redirected to some page"); window.location = "Default.aspx"; }
这篇关于java脚本在asp.net 3.5中倒数计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!