Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2009, 08:16 AM   PM User | #1
r4m39z
New to the CF scene

 
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
r4m39z is an unknown quantity at this point
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?
r4m39z is offline   Reply With Quote
Old 01-03-2009, 10:53 AM   PM User | #2
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
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
itsallkizza is offline   Reply With Quote
Old 01-03-2009, 01:26 PM   PM User | #3
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 is offline   Reply With Quote
Old 01-03-2009, 07:34 PM   PM User | #4
r4m39z
New to the CF scene

 
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
r4m39z is an unknown quantity at this point
Wow Thanks!!

I must have been tired I been working on this thing all night to get it done. Thanks.
r4m39z is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:40 AM.


Advertisement
Log in to turn off these ads.