?
Solved

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

Posted on 2011-09-28
6
Medium Priority
?
287 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

770 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