如何在在线考试中使用计时器控制 [英] how to use timer control in online examination

查看:69
本文介绍了如何在在线考试中使用计时器控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用计时器控制并设置计时器300秒...

当它到达时自动重定向到另一页...

帮助我这样做。 ...

解决方案





你可以在javascript中完成它。这里提供代码试试那个



 <   head     runat   =  server >  
< ; title > < / title >
< script language = javascript >
var sdf;
function f1(){
sdf = setTimeout( f2() 300 );
}
function f2(){
location .href = default2.aspx;
}
< / 脚本 >
< / head >
< body onload = f1() >
< 表格 id = form1 runat = server >
< div >

< / div >
< / form >
< / body >
< / html >





在上面代码你要设定你的时间要求。

这里的时间是毫秒,所以你可以给它正确的时间。



在这里我给你倒计时的时间。



 <   html     xmlns   =  http://www.w3.org/1999/xhtml  >  
< head runat = server >
< title > < / title >
< script language = javascript >
var tim = 10000 ;
var timset;
function f1(){
timset = setInterval( f2() 1000 );
}
function f2(){

tim = parseInt (tim) - 10 ;
if parseInt (tim)< 0 ){
clearInterval(timset);
}
else {
document .getElementById( timershow)。value = tim;
timset = setInterval( f2() 1000 );
}

}
< / < span class =code-leadattribute> script
>
< / head >
< body onload = f1() >
< 表单 id = form1 runa t = server >
< div >
< 输入 类型 = text id = timershow / >
< / div >
< / form >
< / body >
< / html >



所有最好的


你试试这个减少订单..你必须编辑这个代码为你的要求...



 <   html  >  
< body >
< div < span class =code-attribute> id = 倒计时 > < / div >
< div id = 通知程序 > < / div >

< script type = text / javascript >

(function() {
function display(notifier,str){
document.getElementById(notifier).innerHTML = str;
}

函数toMinuteAndSecond(x){
返回Math.floor(x / 60)+:+(x = x%60 < 10 0 x );

}



function setTimer( 保留, 操作 {

var action;

(fu nction 倒计时() {

< span class =code-attribute> display(countdown, toMinuteAndSecond(retain));

如果 (action = 操作[保留]) {

< span class =code-attribute> action();

}

if (保留 > 0){
剩余 - = 1;
setTimeout(arguments.callee,1000);
}
})(); //结束倒计时
}

setTimer(20,{
10:function(){display(notifier,仅需10秒钟);},
5:function(){display(notifier,5秒left);},
0:function(){display(notifier,Time is up baby);}
});
})();

< / script >
< / body >
< / html >





快乐编码......


how to use timer control and set timer 300 seconds ...
when it reach it automatically redirect to another page...
help me to do this....

解决方案

Hi,

you can do it in javascript.Here 'm providing code for try that

<head runat="server">
    <title></title>
    <script language ="javascript">
        var sdf;
        function f1() {
            sdf = setTimeout("f2()", 300);
        }
        function f2() {
            location.href = "default2.aspx";
        }
    </script>
</head>
<body onload="f1()">
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>



In the above code you've to set what is your time requirement.
The time here is in millisec so you can give correct time for it.

Here im giving for count down time for you requirement.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language ="javascript" >
        var tim = 10000;
        var timset;
        function f1() {
            timset = setInterval("f2()", 1000);
        }
        function f2() {

            tim = parseInt(tim) - 10;
            if (parseInt(tim) < 0) {
                clearInterval(timset);
            }
            else {
                document.getElementById("timershow").value = tim;
                timset = setInterval("f2()", 1000);
            }

        }
    </script>
</head>
<body onload ="f1()" >
    <form id="form1" runat="server">
    <div>
      <input type ="text" id="timershow" />
    </div>
    </form>
</body>
</html>


All the best


You try this for decrease order..You have to edit this code for you requirement...

<html>
<body>
<div id="countdown"></div>
<div id="notifier"></div>

<script type="text/javascript">

(function () {
  function display( notifier, str ) {
    document.getElementById(notifier).innerHTML = str;
  }

  function toMinuteAndSecond( x ) {
    return Math.floor(x/60) + ":" + (x=x%60 < 10 ? 0 : x);

  }



  function setTimer( remain, actions ) {

    var action;

    (function countdown() {

       display("countdown", toMinuteAndSecond(remain));

       if (action = actions[remain]) {

         action();

       }

       if (remain > 0) {
         remain -= 1;
         setTimeout(arguments.callee, 1000);
       }
    })(); // End countdown
  }

  setTimer(20, {
    10: function () { display("notifier", "Just 10 seconds to go"); },
     5: function () { display("notifier", "5 seconds left");        },
     0: function () { display("notifier", "Time is up baby");       }
  });
})();

</script>
</body>
</html>



Happy coding....


这篇关于如何在在线考试中使用计时器控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆