Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

js. How to start multiple javascript function on rge body onload function

Posted on 2011-09-28
6
Medium Priority
?
295 Views
Last Modified: 2012-05-12
I need to know how to start multiple JS functions during the body onload

I have these javascript function
<SCRIPT LANGUAGE="JavaScript">
function auto1()
"""
</script>

<SCRIPT LANGUAGE="JavaScript">
function auto2()
''''''
</script>
----------------------------

If I add the script for auto2 how can I get it to run.. I tried <body onload="auto1();auto2()">
and it did not work only auto1 worked.

========================Blow is the script for auto1========================
<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Mike Canonigo (mike@canonigo.com) -->
<!-- Web Site:  http://www.munkeehead.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
NewImg = new Array (
"images/FUN-1.jpg",
"images/FUN-2.jpg",
"images/FUN-3.jpg",
"images/FUN-4.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;

//Time delay between Slides in milliseconds
var delay = 5000;

var lock = false;
var run;
function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow1.src = NewImg[ImgNum];
   }
}
function auto1() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
   }
}
//  End -->
</script>


<body onload="auto1()">

Open in new window

0
Comment
Question by:westdh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36718480
<body onload="auto1();auto2()">

Open in new window

or
<body onload="autos()">

<SCRIPT LANGUAGE="JavaScript">
function autos() {
       auto1();
       auto2();
}
</script>

Open in new window

or
<body>

<SCRIPT LANGUAGE="JavaScript">
window.onload = function() {
       auto1();
       auto2();
}
</script>

Open in new window

0
 
LVL 18

Expert Comment

by:nap0leon
ID: 36718720
@leakim971
Curious - which of these will run synchronously versus asynch? ("one-after-the-other" versus "at the same time")
0
 

Author Comment

by:westdh
ID: 36719000
asynch ("at the same time")
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:westdh
ID: 36719084
Tried all three. None worked
0
 

Author Closing Comment

by:westdh
ID: 36719868
thanks
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36720273
>@leakim971
>Curious - which of these will run synchronously versus asynch? ("one-after-the-other" versus "at the same time")

@nap0leon : no one.

@westdh, I apologize if I misunderstanding your question. I saw the new one about running both at what humans call << the same time >>
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question