473,795 Members | 3,175 Online
Bytes | Software Development & Data Engineering Community
+ 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="SwapImg s()">

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 14338


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="SwapImg s()">

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="SwapImg s()">

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.goo glegroups.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="SwapImg s()">

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.JavaS cript, if not I recommend you
enquire there too.
Signed,
me
Jul 23 '05 #4
me
"me" <anonymous@_.co m> wrote in message
news:11******** *****@corp.supe rnews.com...
"Viken Karaguesian" <vi****@aol.com > wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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="SwapImg s()">

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.JavaS cript, 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.javas cript
Signed,
me
Jul 23 '05 #5

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

Similar topics

1
4431
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
2091
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 1.6, the function msg works fine if it's installed as an onclick handler for the button, but fails as an onload handler for the page. The error is "console has no properties", and is triggered by the line.
2
2448
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 the client, there is no guarantee that the document has finished loading, and that the DOM is ready to be accessed.
7
6218
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): <HTML> <HEAD> .... </HEAD> <BODY onload="ShowPopUp();" MS_POSITIONING="GridLayout"> ....
1
8749
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 anything that works.. I thought about cookies, but what if the user's disable them? My code: //I want to call the Toggle function below only on the 1st time the page is loaded:
22
130431
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 document and closes it with the following code: <body onload="window.print(); window.close();"> This works correctly (or at least the way I expect it to work under MS Internet Explorer, but it cuases Netscape to "crash"
4
14475
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. Bottomline is: Firefox doesn't accept window.close() or self.close()? Are there ways to rectify the issue? Please advise.
5
2314
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 somewhere except within the body tag, or must it always be in the body tag? For example, if this is placed elsewhere ... window.onload(something())
1
3808
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 problem is that the ITV gets executed for the first time on document's onload method. When the page has few thumb images there are no problems. But when you have big galeries, the behavior of anchors/links isn't the desired until the ITV runs. So I...
0
10213
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
10163
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
9040
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
7538
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...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.