faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 10 people (60%) answered Yes
Recently 4 of 8 people (50%) answered Yes

Entry

How do I call an object´s function using setTimeout()?

Apr 4th, 2008 21:14
ha mo, Dave Clark, Colin Fraser, Michel Petrovic,


Try this: 
<script language="JavaScript"><!--
function doWhatever() {
  //do what you want here 
  //use the code but nils illegitimati carborundum
}
function setupDelay() {
   setTimeout('doWhatever()',10000);
}
setupDelay(); // start the function
//--></script>
This should delay the executon of the doWhatever() function for 10 
seconds.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michel,
Perhaps you're referring to being able to pass an object within the 
setTimeout() process.  The following example will execute the 
specified object's method after a one-second delay:
window.setTimeout(function() { myObject.myMethod() }, 1000);
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com