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

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?

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">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<script type="text/javascript">
// <![CDATA[

function SuperSetTimeout(str_func,ms)
this.str_func = str_func;
this.ms = ms;
this.start = function()
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);
document.body.innerHTML = "my_timeout.ms = "+my_timeout.ms;

// ]]>


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. :)


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.