如何在在线考试中使用计时器控制

编程入门 行业动态 更新时间:2024-10-12 03:27:53
本文介绍了如何在在线考试中使用计时器控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何使用计时器控制并设置计时器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 = www.w3/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() > < 表单 id = form1 runa t = server > < div > < 输入 类型 = text id = timershow / > < / div > < / form > < / body > < / html >

所有最好的

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

< html > < body > < div 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 倒计时() { display(countdown, toMinuteAndSecond(retain)); 如果 (action = 操作[保留]) { 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="www.w3/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....

更多推荐

如何在在线考试中使用计时器控制

本文发布于:2023-11-27 16:31:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638756.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在线   计时器   考试

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!