473,657 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help With setTimeout

There is no problem with the following function. I want to insert code
at the point that the function does not repeat. I was pretty sure that
it could be inserted at the /// but that repeats with every loop. What
happens after the setTimeout? Does the flow continue through the bottom
of the function every time? How can I trap it on the last loop?
function moveTrain() {
if (MenuX < PosX) {
MenuX = MenuX + increment;
if (is_NS5up) {
document.getEle mentById('train Division').styl e.left = MenuX+"px";
}
else {
eval(Lq+'trainD ivision'+Sq+'.l eft=MenuX');
}
setTimeout('mov eTrain()',speed );
}
///
}

--
Dennis M. Marks
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #1
3 1429
In article <13************ *************@d csi.net>, Dennis M. Marks
<de******@dcsi. net> wrote:
There is no problem with the following function. I want to insert code
at the point that the function does not repeat. I was pretty sure that
it could be inserted at the /// but that repeats with every loop. What
happens after the setTimeout? Does the flow continue through the bottom
of the function every time? How can I trap it on the last loop?
function moveTrain() {
if (MenuX < PosX) {
MenuX = MenuX + increment;
if (is_NS5up) {
document.getEle mentById('train Division').styl e.left = MenuX+"px";
}
else {
eval(Lq+'trainD ivision'+Sq+'.l eft=MenuX');
}
setTimeout('mov eTrain()',speed );
}
///
}

It looks like there is no practical way to start a sound using
javascript that will work on most browsers therefore I don't need a way
to insert commands.

--
Dennis M. Marks
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #2
"Dennis M. Marks" <de******@dcsi. net> writes:
There is no problem with the following function.
I can see some ;)
I want to insert code at the point that the function does not
repeat. I was pretty sure that it could be inserted at the /// but
that repeats with every loop.
Either put it after an "else" or put a return after the call to
"setTimeout ".
What happens after the setTimeout?
The next line, just as any other function call. Calls to "setTimeout "
returns instantly, and evaluation continues.
Now for the comments:
function moveTrain() {
if (MenuX < PosX) {
MenuX = MenuX + increment;
if (is_NS5up) {
Browser detection is rarely safe. You should test for the existence
of the features you use instead:

if (document.getEl ementById) {
document.getEle mentById('train Division').styl e.left = MenuX+"px";
}
else {
eval(Lq+'trainD ivision'+Sq+'.l eft=MenuX');
You don't need eval for this. I don't know what Lq and Sq are, but you
never need to use eval for accessing properties or variables. It is
slow, inefficient, and hard to debug.

How about:
if (document.all) {
document.all['trainDivision'].style.left=Men uX+"px";
} else if (document.layer s) {
document.layers['trainDivision'].left = MenuX;
} else { //panic and try something desperate:
window['trainDivision'].left = MenuX;
}
}
setTimeout('mov eTrain()',speed );
}
///

else {
///
}

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
In article <is**********@h otpop.com>, Lasse Reichstein Nielsen
<lr*@hotpop.com > wrote:
"Dennis M. Marks" <de******@dcsi. net> writes:
There is no problem with the following function.


I can see some ;)
I want to insert code at the point that the function does not
repeat. I was pretty sure that it could be inserted at the /// but
that repeats with every loop.


Either put it after an "else" or put a return after the call to
"setTimeout ".
What happens after the setTimeout?


The next line, just as any other function call. Calls to "setTimeout "
returns instantly, and evaluation continues.
Now for the comments:

(snip>
Thank you for the information and comments. This was part of a script
that I found on a javascript site. It was for a slide out menu. I am
modifing but not rewriting it to have a train move across the screen
and stop in the middle. I wanted to say "all aboard" when it stopped
and needed a place to insert the code.

I have not been able to find a way to have a sound start using a
script. Can anyone help? I will use "else" if I can find code.

--
Dennis M. Marks
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2495
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only. For example, here is the main page: <html> <head> <script type="text/javascript">
4
2934
by: Mool | last post by:
I want to use a setTimeout to just loop for a number of seconds, then fall through to the next bit of code...can this be done by using some kind of null in the statement, or do I have to assign the code a name and call it from the setTimeout once it's done? Thanks so much!
4
8400
by: Ken | last post by:
Hello I am trying to change the color of a font in a text box. I have been reading about and trying various examples found it this group, but still can't get it right. Here is where I am now: <script language="JavaScript">
3
1769
by: P Wolpert | last post by:
This is my first post. I hope I don't sound stupid. I have a script conflict when I put two scripts on one page. Both scripts will work if I use one at a time but the menu button script will not work when I add the scrolling text script. One script, the menu button script, has an "Onload" command and the other one does not. From what I know, and that's not much, I need to put both scripts in the "Onload" command. I just don't know how to...
2
3876
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it is not possible, therefore assuming it is a client script problem? the script works last time...
12
5538
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
4
5222
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...
2
1835
by: jasonchan | last post by:
I am trying to have a function start with a timer and then switch to another function. However, it is not working at all. Anyone know whats goin on? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script...
0
8325
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,...
0
8742
jinu1996
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...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
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...
0
7354
agi2029
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...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.