Solved

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

Posted on 2011-09-28
6
268 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
  • 3
  • 2
6 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
date format angularjs2 16 41
jQuery Animate Left Right 2 44
HTML page and JavaScript 2 54
Hovering effect 9 29
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now