Your code configures both functions for execution onload by including them here:
Code:
StkFunc(initImage);
StkFunc(initImage1);
If everything else were written logically, all you would have to do is remove one of those statements and call the other when the one you keep as onload has completed.
However, one of your functions isn't completely logical:
Code:
function fadeIn1(objId,opacity1) {
if (document.getElementById) {
obj = document.getElementById(objId);
if (opacity1 >= 0) {
setOpacity1(obj, opacity1);
opacity1 +=2;
window.setTimeout("fadeIn1('"+objId+"',"+opacity1+")", 200);
}
}
}
In that function, opacity1 will either always be >=0, or it will never be. When you do this first, as is done in your code:
Code:
function initImage1() {
var image1 = document.getElementById('text');
setOpacity1(image1, 0);
fadeIn1('text',0);
}
it will always be.
So, first change fadeIn1 to:
Code:
function fadeIn1(objId,opacity1) {
if (document.getElementById) {
obj = document.getElementById(objId);
if (opacity1 < 100) {
setOpacity1(obj, opacity1);
opacity1 +=2;
window.setTimeout("fadeIn1('"+objId+"',"+opacity1+")", 200);
}
}
}
Now you pick whichever one you want to happen onload and keep it here:
Code:
StkFunc(initImage);
StkFunc(initImage1);
Let's say it's initImage, then use just:
Code:
StkFunc(initImage);
and at the end of fadeIn, do this:
Code:
function fadeIn(objId,opacity2) {
if (document.getElementById) {
obj = document.getElementById(objId);
if (opacity2 >= 0) {
setOpacity(obj, opacity2);
opacity2 -= 4;
window.setTimeout("fadeIn('"+objId+"',"+opacity2+")", 50);
}
else
initImage1();
}
}
If you want the order of the actions reversed, you could keep the other init and add the first one to the end of the other fadeIn.
Note: There are other things I don't like about this code, and there could be other problems. But, the above answers your question.
Bookmarks