473,473 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to format two "Body Onload" commands?

Hello all,

I have a question. I trying to run two Javascripts on my webpage, both
of which need a <body onload> command. They are as follows:

<body onload="runMe()">
<body onload="SwapImgs()">

What would be the proper format to include these on the same line?
would it be:

<body onload="runMe(),SwapImgs()">
or
<body onload="runMe()";"SwapImgs()">

I'd like to get these working together and at the moment, I can't.
Thanks in advance for your replies.

Viken K.

Jul 23 '05 #1
4 14316


Viken Karaguesian wrote:

I have a question. I trying to run two Javascripts on my webpage, both
of which need a <body onload> command. They are as follows:

<body onload="runMe()">
<body onload="SwapImgs()">

What would be the proper format to include these on the same line?


Use
<body onload="runMe(); SwapImgs();">
a sequence of statements in JavaScript is separated by a semicolon.

You could also write a function calling those other functions e.g.
<script type="text/javascript">
function init () {
runMe();
SwapImgs();
}
</script>

<body onload="init();">
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
"Viken Karaguesian" <vi****@aol.com> wrote:
I have a question. I trying to run two Javascripts on my webpage, both
of which need a <body onload> command. They are as follows:

<body onload="runMe()">
<body onload="SwapImgs()">

What would be the proper format to include these on the same line?
would it be:

<body onload="runMe(),SwapImgs()">
or
<body onload="runMe()";"SwapImgs()">


Close.
<body onload="runMe();SwapImgs()">

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 23 '05 #3
me
"Viken Karaguesian" <vi****@aol.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello all,

I have a question. I trying to run two Javascripts on my webpage, both
of which need a <body onload> command. They are as follows:

<body onload="runMe()">
<body onload="SwapImgs()">

What would be the proper format to include these on the same line?
would it be:

<body onload="runMe(),SwapImgs()">
or
<body onload="runMe()";"SwapImgs()">

I'd like to get these working together and at the moment, I can't.
Thanks in advance for your replies.

Viken K.


Have you asked your question in comp.lang.JavaScript, if not I recommend you
enquire there too.
Signed,
me
Jul 23 '05 #4
me
"me" <anonymous@_.com> wrote in message
news:11*************@corp.supernews.com...
"Viken Karaguesian" <vi****@aol.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello all,

I have a question. I trying to run two Javascripts on my webpage, both
of which need a <body onload> command. They are as follows:

<body onload="runMe()">
<body onload="SwapImgs()">

What would be the proper format to include these on the same line?
would it be:

<body onload="runMe(),SwapImgs()">
or
<body onload="runMe()";"SwapImgs()">

I'd like to get these working together and at the moment, I can't.
Thanks in advance for your replies.

Viken K.
Have you asked your question in comp.lang.JavaScript, if not I recommend

you enquire there too.
Signed,
me


Corruption by spell checker encountered. Here's the correct name of that NG:
comp.lang.javascript
Signed,
me
Jul 23 '05 #5

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

Similar topics

1
by: Peter Cartwright | last post by:
Is there a functional equivalent to <body onload="function call" in the main script. Can one do something like document.body.onload=function call?
3
by: kj | last post by:
This problem is driving me nuts. The code at the end of this post below works fine with IE, but fails with Mozilla. You can see it in action at http://tinyurl.com/2jvo3 With Mozilla 1.4 and...
2
by: cmay | last post by:
I have recently been working with RegisterStartScript in my asp.net pages. However, as you probably know it places the script at the end of the FORM tag. However, when this code executes on...
7
by: Calvin KD | last post by:
Hi everyone, Has someone out there experienced the same problem? What i wanted to do is to display a popup window (modal) upon the loading of a webpage. Here is my code sample (in html view):...
1
by: lwhitb1 | last post by:
I have been trying to load a javascript function from the body onload html tag, but I only want the function to load the first time the page is loaded: I have investigated but haven't found...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
4
by: stevong | last post by:
It works on Konquerer though. I remember it works on IE too. I've tried window.close() too. Doesn't work on Firefox also. I've also tried to create a function. It doesnt work on Firefox also....
5
by: tuxedo | last post by:
The way the <body onload="something()"works ensures that the complete html document is loaded before something() is executed. Can the same be achieved when placing the onload call in document...
1
Cristian Pinheiro
by: Cristian Pinheiro | last post by:
Hello guys, I was playing with Image Thumbnail Viewer (ITV) and found one problem, see http://www.dynamicdrive.com/dynamicindex4/thumbnail.htm for more details and how it works. Now the...
0
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...
0
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...
1
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...
0
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...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
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...

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.