Hi,
Can someone help me with the command format please.
I have a function (called fade) that was 3 parameters:
the first 2 are colours therefore formatted #123456
and the 3rd is a number of milliseconds.
A normal call to the function therefore looks like this: - fade("#FFFFFF", "#000000", 1000);
// ie fades from white to black over 1 sec.
this works fine, but I now want to delay the start of the function.
So I tried; - setTimeout('fade("#FFFFFF", "#000000". 1000)' , 2000);
// to delay start by 2 secs
then realised that I needed to take care of the quotes .. so tried lots! of attempts like: - setTimeout('fade(\"#FFFFFF\", \"#000000\", 1000)', 2000)
but none of my attempts work.
Could someone guide me please.
Thanks
5 3278
setTimeout and setInterval will accept a function as the first argument-
setTimeout(func tion(){fade("#F FFFFF", "#000000")} , 1000);
setTimeout and setInterval will accept a function as the first argument-
setTimeout(func tion(){fade("#F FFFFF", "#000000")} , 1000);
Thanks, Unfortunately, it didnt work, but then I noticed the 3rd parm was missing, so I added the 3rd parameter to your suggestion as follows:
setTimeout(func tion(){fade("#F FFFFF", "#000000", 2000)}, 1000);
(I also tried wrapping the 2000 with "s (ie "2000"), but in neither case did it work.?
Correction:
It DOES now work with the 2000 wrapped in "s (ie "2000")
Thanks VERY much for your help. I would never have found this solution without your help!
I am using a function that fades the background between 2 colours over n secs.
It works fine.
I now need to delay the start of the fade - so I tried setTimeout, which (seemingly) allows a delay before the function is called.
eg If I set fade time to 2 secs, and delay_time to 5 secs ... it doesnt seem to work as intended.
Can someone help me understand how setTimeout works.
1) Does it delay the calling of the function for n secs?,
or
2) Does it delay the return from the function?
If 2) above, is there another solution I could use?
Thanks for your help.
acoder 16,027
Recognized Expert Moderator MVP
I've merged your threads because they relate to the same problem.
See if this link helps you to understand setTimeout. If not, post your code (including fade()).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Raphael Bauduin |
last post by:
Hi,
I'm working with mozilla, building a little XUL app.
I have a datasource, and want to display a message
once it is loaded (datasource.loaded is true).
So, I thought to use timouts, but as the code to execute is
passed as a string, I cannot pass local variable to this code.
Anyone has a suggestion?
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {
document.images.src = eval("mt" +menu+ ".src")
}
alert("imgOff_hidemenu");
hideMenu=setTimeout('Hide(menu,num)',500);
|
by: Noh Way |
last post by:
I have a stack of DOM elements and I have stored their IDs in an array. I
want to press a button - this code is from that button's event's function-
and have a slideshow as each element is brought to the top, in turn. All
this, with a user definable delay (currently fixed in the code at 5 secs). I
cannot get the loop to stop while the interval timer is counting the time.
Help please :o?
Greg
|
by: Mic |
last post by:
Goal: delay execution of form submit
Code (Javascript + JScript ASP):
<%
Response.Write("<OBJECT ID='IntraLaunch' STYLE='display : none'
WIDTH=0 HEIGHT=0 CLASSID='CLSID:0AE533FE-B805-4FD6-8AE1-A619FBEE7A23'
CODEBASE='IntraLaunch.CAB#version=5,0,0,3'>")
Response.Write("<PARAM NAME='ImageLoc' VALUE='Null'>")
Response.Write("<PARAM NAME='ImageSrc' VALUE='Null'>")
|
by: Andre |
last post by:
Hi,
Does anyone know whether the ECMA, or an other standard document,
specifies a maximum for the value that can be pass to the setTimeOut()
function in Javascript?
Andre
| |
by: E |
last post by:
I am having trouble with setTimeout working on a second call to the
setTimeout function from a second page which is an html page.
Here is the scenario.
I have a web page and onload it calls a javascript function which calls
setTimeout and will process a second javascript function "Warn" just before
the session expires. The Warn function displays an html page with a
button. A second timer is started to cause the html page to close...
|
by: Chris Moltisanti |
last post by:
Hey,
I am using the setTimeout() function in IE to pause the execution of
another funciton for a few seconds. My function is as follows:
funtion test(e) {
// the parameter 'e' is the event
// do something
}
|
by: barry |
last post by:
I'm having a problem creating a delay before each list item gets moved
( http://www.polisource.com/PublicMisc/list-splitter-timeout-bug.html
). Choose any number of columns, vertical layout, and view as a web
page. They'll be a small delay before the entire bunch of list items
converts from left-to-right to top-to-bottom order. I expected a delay
before each item is moved. It looks like I have to flush the buffer to
get setTimeout to work,...
|
by: phocis |
last post by:
I wrote a pair of functions to enable scoped or referenced setTimeout
calls. I did this because I have an object factory that creates
multiple objects and those objects need to delay a few calls on
themselves at a certain point in time.
This code works fine for normal objects. However, my issue occurs if
at any point, an event object is passed across in IE.
It seems, that events methods and variables in IE are PRIVATE (!)
after the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |