...

View Full Version : I have a challenge for you guys.. (setTimeout)



r4m39z
01-03-2009, 09:16 AM
ok I need to return the milliseconds from a setTimeout command/or function..

something like:


setTimeout("whatever()" ,2000);

var return = setTimeout.argument.2000;


I have no idea how this would work but as you can see I need the actual number that was executed to be returned. Maybe there is a better way of doing something like this this?

itsallkizza
01-03-2009, 11:53 AM
How's this work for ya:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example</title>
<style type="text/css">
</style>
<script type="text/javascript">
// <![CDATA[

function SuperSetTimeout(str_func,ms)
{
this.str_func = str_func;
this.ms = ms;
this.start = function()
{
this.cancel();
this.ref = setTimeout(this.str_func,this.ms);
}
this.cancel = function()
{
if (this.ref) clearTimeout(this.ref);
}
}

window.onload = function()
{
var my_timeout = new SuperSetTimeout("alert('hey')",4000);
my_timeout.start();
document.body.innerHTML = "my_timeout.ms = "+my_timeout.ms;
}

// ]]>
</script>
</head>
<body>

</body>
</html>

A1ien51
01-03-2009, 02:26 PM
Don't make things seem like it is a competition if you have no clue how to do it. Just ask your question. :)

Eric

r4m39z
01-03-2009, 08:34 PM
Wow Thanks!! :eek:

I must have been tired I been working on this thing all night to get it done. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum