PDA

View Full Version : Script in table overrides a preloaded one(?)



mkr
09-01-2005, 08:54 AM
Hi! :-)

DD Fade-in slideshow
http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm

I just made a menu involving two scripts; one is supposed to exchange menu buttons while the user hovers over the link with the mouse (this one is generated by Adobe ImageReady), the other one is the great DD Fade-in slideshow which I like very much because it works so neatly. :-)

I got the impression that on the page in question (http://michaelkrefft.com/sandbox/sylva/menu.html) the slideshow overrides the ONLOAD command in the body tag. Is that true? How could I possibly avoid this?

Thanks for helping! :-)

Cheers!

Twey
09-01-2005, 09:39 AM
if (ie4||dom)
window.onload+=startit
else
setInterval("rotateimage()",pause)
Just add in the + sign, and it'll stop overwriting it.

mkr
09-01-2005, 11:31 AM
Thanks Twey for the quick reply, but I'm afraid this didnt work at all. Where there is a + or not doesnt make a difference. :(

Another funny thing I noticed (just for the details):
- In both IE and Firefox I cant get those two scripts to work at the same time.
- In Opera, both scripts work fine (although the Crossfader doesnt really crossfade, it shows the next image instantly after the set delay.)

*puzzled*

Twey
09-01-2005, 11:53 AM
Well, it's not the onload that's being overridden, then.
Opera doesn't support transparency, hence the script not working as it should.
There's nothing else I can see that would interfere between the two scripts. Upload the latest version (with the plus) and let me have a look.

mkr
09-01-2005, 01:55 PM
Thanks!

1) Unmodified (http://michaelkrefft.com/sandbox/sylva/menu.html)
2) With a "plus" by Twey (http://michaelkrefft.com/sandbox/sylva/menuplus.html)
3) Without the Crossfader script, shows how the menu should look like (onmouseover) (http://michaelkrefft.com/sandbox/sylva/menunofade.html)

Twey
09-01-2005, 02:33 PM
Try changing

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}
to

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var j=0; j<changeImages.arguments.length; j+=2) {
document[changeImages.arguments[j]].src = changeImages.arguments[j+1];
}
}
}

jscheuer1
09-01-2005, 03:15 PM
Changing the name of a local variable should not make any difference and window.onload+= is unconventional at best, probably unreliable. I'd have changed:

if (ie4||dom)
window.onload=startit
else
setInterval("rotateimage()",pause)to:

if (ie4||dom){
if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", startit, false );
else if ( typeof window.attachEvent != "undefined" ) {
window.attachEvent( "onload", startit );
}
else {
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
startit();
};
}
else
window.onload = startit;
}
}
else
setInterval("rotateimage()",pause)and be done with it. Works here.

mkr
09-01-2005, 04:16 PM
Terrific! This works! Thanks a bunch! :cool:

Thanks guys, thou shalt be credited!

Spinethetic
09-01-2005, 04:22 PM
I dont know if this would help any but when I do image rollovers I just use the DOM and it has never conflicted with any other scripts I happen to have running:


<a href="photos.htm" onmouseover="photosbutton.src='photobuttonover.gif';" onmouseout="photobutton.src='photobuttonout.gif';"><img border="0" src="photobuttonout.gif" name="photobutton"></a>

And then you can always use CSS to position the fading effect, or tables if you want.