PDA

View Full Version : Fix code for 2 body on loads


Ron
10-01-2003, 05:24 PM
Here's what i have now
===============================
<body bgcolor="#d8d4c9" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" link="blue"

VLINK="blue" ALINK="red" onload="window.defaultStatus='Best Links -Best Variety'">
================================

I want to add <BODY onLoad="cycleImg()">
but here's the trick for having 2 of them, but i can't code it right, anyone help?


Adding more than one JavaScript to a page

The solution

The way to go about solving this conflict is simple, though not quite the same to explain. Essentially, what you want is to end up with only ONE delta for both scripts, with that delta calling the two scripts. Let's list some possible scenarios now, and their resolutions:

EXAMPLE #1:
SCRIPT 1: <body onload="dothis()">
SCRIPT 2: <body onload="dothat()">
RESOLUTION: <body onload="dothis();dothat()">

EXAMPLE #2:
SCRIPT 1: <body onload="dothis()">
SCRIPT 2: window.onload=dothat()
RESOLUTION: <body onload="dothis();dothat()">

EXAMPLE #3:
SCRIPT 1: window.onload=dothis
SCRIPT 2: window.onload=dothat
RESOLUTION: <body onload="dothis();dothat()">

As you can see, regardless of whether the two scripts contain "delta" or "beta", the resolution is the same- remove BOTH lines, and call the scripts directly within the <body> tag, each separated by a semicolon. If you wish to combine three scripts, the procedure is the exact same.

-ron

Flash ho
10-02-2003, 12:32 AM
can you post the java scripts? then someone can combine them

Ron
10-02-2003, 11:39 AM
I did..... read it again :wink:
it says - here's what i have now-
and- i want to add this -
=================

Here's what i have now
===============================
<body bgcolor="#d8d4c9" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" link="blue" VLINK="blue" ALINK="red" onload="window.defaultStatus='Best Links -Best Variety'">
================================

I want to add <BODY onLoad="cycleImg()">

Shane
10-02-2003, 12:24 PM
You just posted the onload events, Richard means post the javascripts themselves.

Once combined you can call them with one onload event.

Flash ho
10-02-2003, 02:46 PM
or is this all you need?? :)

<body onload="dothis();dothat()"> //not tested


<body onload="window.defaultStatus="Best Links -Best Variety();cycleImg()">

Ron
10-02-2003, 06:35 PM
That's it, thanks Richard!
My eyes aren't so good anymore to see those little, tight spaces and puntuation stuff....lol

Shane,
I'll get back later on that flash logo, i tried it, but....
i changed the text alright but don't know how to or what html code to put in my source to place it in the spot where i want it.
Too many plates on my table right now, i'm working on my Newsletter right now, and i'm late with it, maybe Shawn can guide me on it this w-end.
I wish someone with dial-up could have timed my new index page, cause if it's too long loading, i could probably take off some graphics. I wonder if all the java scripts i put on there help slow the loading of the page?

GO YANKEES !!!!!!!!!!!!!!!!

Flash ho
10-02-2003, 08:34 PM
ron, use a dial up emulator to test on slow connections, Mr, TC had one here or just search google, there are tons of em