帮助找到这个 [英] help finding this

查看:60
本文介绍了帮助找到这个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我不是js程序员,但我希望找到一个预先编写的脚本

,我可以使用它。所有我需要的是一个简单的计数器计时器,

有一个开始,暂停和停止控制,我找到了一些,但是他们

似乎都重置了一次你把它们暂停了,我需要它停留在它的位置,然后一旦有人点击

重新开始,它就会从暂停的点继续。


如果有人知道我在哪里可以找到这样的东西我会很感激

它。


谢谢

解决方案

Bob写道:


我不是js程序员,但我希望找到一个预先写好的脚本

,我可以使用。所有我需要的是一个简单的计数器计时器,

有一个开始,暂停和停止控制,我找到了一些,但是他们

似乎都重置了一次你把它们暂停了,我需要它停留在它的位置,然后一旦有人点击

重启,它就会从暂停的点继续。



< html>

< head>

< meta http-equiv ="内容-Type"

content =" text / html; charset = iso-8859-1">

< script language =" javascript" type =" text / javascript">

i = 50 //更大=更慢,更小=更快

tR = false

function sTime (){b / b $ b ++ document.c.cf.value

T = setTimeout('sTime()'',i)

tR = true;

}

函数cTime(arg){

if(tR)clearTimeout(T)

tR = false

if(arg == 1)sTime()

if(arg == 3)document.c.cf.value = 0

}

< / script>

< / head>


< body>

< form name =" c">

< input type =" text"名称= QUOT; CF" value =" 0">

< input type =" button"值= QUOT;开始" onClick =" cTime(1)">

< input type =" button"值= QUOT;暂停" onClick =" cTime(2)"

< input type =" button"值= QUOT;复位" onClick =" cTime(3)"

< / form>

< / body>

< / html> ;


希望这会有所帮助,


-

巴特




Bob写道:


你好,


我不是一名js程序员,但我希望找到一个我可以使用的预写脚本

。所有我需要的是一个简单的计数器计时器,

有一个开始,暂停和停止控制,我找到了一些,但是他们

似乎都重置了一次你把它们暂停了,我需要它停留在它的位置,然后一旦有人点击

重启,它就会从暂停的点继续。



如果你想要一个合理准确计算秒数的计数器,你需要使用一个日期对象并每50ms左右运行一次计数器获取

系统时间并使用它来计算大致相等的秒数。


如果你只想要一个大约每100ms运行一次的计数器和时间

准确性并不重要,那么下面的脚本就可以完成这项工作。

< script type =" text / javascript">

>
var pageCounter =(function()

{

var counterLag = 100; //更新之间的毫秒数

var counterValue = 0; //初始值

var counterRef; //对当前计时器的引用

var textElement; //显示值的元素


返回{


//初始化值并启动计时器如果没有
//已经运行了。不要把计数器归零

start:function(id)

{

if(!document.getElementById)return;

textElement = document.getElementById(id);

if(!textElement)return;

if (!counterRef)pageCounter.run();

},


//运行计数器 - 使用setTimeout自行调用

//合理定期更新计数器。

run:function()

{

textElement.innerHTML = counterValue ++;

counterRef = setTimeout(''pageCounter.run()'',counterLag);

},


//停止柜台但不要零点柜台

停止:功能()

{

if(counterRef)clearTimeout(counterRef);

counterRef = null;

},


//停止并将计数器归零

clear:function()

{

if(counterRef)pageCounter.stop();

counterValue = 0;

textElement.innerHTML = counterValue;

}

}

})();


< / scri pt>


< button onclick =" pageCounter.start(''xx'')">开始< /按钮>

< button onclick =" pageCounter.stop()"> Stop< / button>

< button onclick =" pageCounter.clear()"> Clear< / button>


< br>< span id =" xx">< / span>

-

Rob


是的,我需要有一些非常准确的东西,我需要它在一秒钟或一秒钟之内成为
3分钟的时间。


另一个问题:如果我将它用作countDOWN,这会更准确吗?

再次,谢谢。


RobG写道:


Bob写道:
< blockquote class =post_quotes>
您好,


我不是js程序员,但我希望找到一个预先编写的脚本

我或许可以使用。所有我需要的是一个简单的计数器计时器,

有一个开始,暂停和停止控制,我找到了一些,但是他们

似乎都重置了一次你把它们暂停了,我需要它停留在它的位置,然后一旦有人点击

重启,它就会从暂停的点继续。



如果你想要一个能够合理准确计算秒数的计数器,你需要使用一个日期对象并且每50ms左右运行一次计数器获取

系统时间并使用它来计算大致相等的秒数。


如果你只想要一个大约每100ms运行一次的计数器和时间

准确度并不重要,那么下面的脚本就可以完成这项工作。


< script type =" text / javascript">


var pageCounter =(function()

{

var counterLag = 100; //更新之间的毫秒数

var counterValue = 0; //初始值

var counterRef; //对当前计时器的引用

var textElement; //显示值的元素


返回{


//初始化值并启动计时器,如果一个人不是
//已经运行了.Don'' t零计数器

start:function(id )

{

如果(!document.getElementById)返回;

textElement = document.getElementById(id);

if(!textElement)return;

if(!counterRef)pageCounter.run();

},


//运行计数器 - 使用setTimeout自行调用

//并更新计数器。

run:function()

{

textElement.innerHTML = counterValue ++;

counterRef = setTimeout(''pageCounter.run()'',counterLag);

},< br $>

//停止柜台,但不要把柜台归零

停止:功能()

{

if(counterRef)clearTimeout(counterRef);

counterRef = null;

},


//停止并将计数器归零

clear:function()

{

if(counterRef)pageCounter.stop();

counterValue = 0;

textElement.innerHTML = counterValue;

}

}

})();


< / script>


< button onclick =" pageCounter.start(''xx'')"> Start< ; / button>

< button onclick =" pageCounter.stop()">停止< /按钮>

< button onclick =" pageCounter。 clear()"> Clear< / button>

< br>< span id =" xx">< / span>


-

Rob


Hello,

I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.

if anyone knows where i can find something like this i would appreciate
it.

Thank you

解决方案

Bob wrote:

I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.

<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript">
i = 50 // bigger = slower, smaller = faster
tR = false
function sTime() {
++ document.c.cf.value
T = setTimeout(''sTime()'', i)
tR=true;
}
function cTime(arg) {
if (tR) clearTimeout(T)
tR = false
if (arg == 1) sTime()
if (arg == 3) document.c.cf.value = 0
}
</script>
</head>

<body>
<form name="c">
<input type="text" name="cf" value="0">
<input type="button" value="Start" onClick="cTime(1)">
<input type="button" value="Pause" onClick="cTime(2)">
<input type="button" value="Reset" onClick="cTime(3)">
</form>
</body>
</html>

Hope this helps,

--
Bart



Bob wrote:

Hello,

I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.

If you want a counter that resonably accurately counts seconds, you
need to use a date object and run the counter every 50ms or so to grab
the system time and use that to count in roughly equal seconds.

If you just want a counter that runs about every 100ms or so and time
accuracy is not important, then the script below will do the job.
<script type="text/javascript">

var pageCounter = (function()
{
var counterLag = 100; // Milliseconds between updates
var counterValue = 0; // Initial value
var counterRef; // Reference to current timer
var textElement; // Element to displaying value

return {

// Initialise values and start the timer if one isn''t
// running already. Don''t zero the counter
start : function(id)
{
if (!document.getElementById) return;
textElement = document.getElementById(id);
if (!textElement) return;
if (!counterRef) pageCounter.run();
},

// Run the counter - uses setTimeout to call itself
// reasonably regularly and update the counter.
run : function()
{
textElement.innerHTML = counterValue++;
counterRef = setTimeout(''pageCounter.run()'', counterLag);
},

// Stop the counter but don''t zero the counter
stop : function()
{
if (counterRef) clearTimeout(counterRef);
counterRef = null;
},

// Stop and zero the counter
clear : function()
{
if (counterRef) pageCounter.stop();
counterValue = 0;
textElement.innerHTML = counterValue;
}
}
})();

</script>

<button onclick="pageCounter.start(''xx'')">Start</button>
<button onclick="pageCounter.stop()">Stop</button>
<button onclick="pageCounter.clear()">Clear</button>

<br><span id="xx"></span>
--
Rob


yeah, i need to have something that is pretty accurate, i need it to be
within a second or 2 after a 3 minute period.

another question: if i were to use it as a countDOWN, would this be
more accurate?

once again, thank you.

RobG wrote:

Bob wrote:

Hello,

I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.


If you want a counter that resonably accurately counts seconds, you
need to use a date object and run the counter every 50ms or so to grab
the system time and use that to count in roughly equal seconds.

If you just want a counter that runs about every 100ms or so and time
accuracy is not important, then the script below will do the job.
<script type="text/javascript">

var pageCounter = (function()
{
var counterLag = 100; // Milliseconds between updates
var counterValue = 0; // Initial value
var counterRef; // Reference to current timer
var textElement; // Element to displaying value

return {

// Initialise values and start the timer if one isn''t
// running already. Don''t zero the counter
start : function(id)
{
if (!document.getElementById) return;
textElement = document.getElementById(id);
if (!textElement) return;
if (!counterRef) pageCounter.run();
},

// Run the counter - uses setTimeout to call itself
// reasonably regularly and update the counter.
run : function()
{
textElement.innerHTML = counterValue++;
counterRef = setTimeout(''pageCounter.run()'', counterLag);
},

// Stop the counter but don''t zero the counter
stop : function()
{
if (counterRef) clearTimeout(counterRef);
counterRef = null;
},

// Stop and zero the counter
clear : function()
{
if (counterRef) pageCounter.stop();
counterValue = 0;
textElement.innerHTML = counterValue;
}
}
})();

</script>

<button onclick="pageCounter.start(''xx'')">Start</button>
<button onclick="pageCounter.stop()">Stop</button>
<button onclick="pageCounter.clear()">Clear</button>

<br><span id="xx"></span>
--
Rob


这篇关于帮助找到这个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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