Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I have a challenge for you guys.. (setTimeout)

    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?

  • #2
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    How's this work for ya:
    Code:
    <!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>
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Don't make things seem like it is a competition if you have no clue how to do it. Just ask your question.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #4
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow Thanks!!

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •