Closed Thread Icon

Topic awaiting preservation: zipplet question (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8187" title="Pages that link to Topic awaiting preservation: zipplet question (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: zipplet question <span class="small">(Page 1 of 1)</span>\

 
anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-26-2002 17:55

i'm using doc's handy zscrollbars (version 1) scripts. i got it working and all, but i noticed whenever i use an onLoad function call in the body tags, the zscrollbars stops showing up. how do i fix this?

one more question. i have a bunch of files called "thumbs#.jpg" in a folder "thumbs" and i want to preload them all. i'm not sure if my code is right but i didn't get errors. here's my code:

code:
var imglist = new Array ();
for (var j=1; j<28; j++) {
imglist[j]='thumbs/thumb'+j+'.jpg';
}
var count;
if (document.images)
for (count=0; count<imglist.length; count++) {
imgs[count]=new Image(); imgs[count].src=imglist[count];
}



would that set the array element to 'thumbs/thumb1.jpg'? i thought you had to use the eval() to do it but eval gave me errors.


[This message has been edited by anomaly (edited 05-26-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-26-2002 18:03

That code will work fine, but won't do what you intended. It will make an array of strings, giving them each the pathname of an image. However, it won't preload the image.

To preload the image, you have to make each element into an Image object, and then set its source. (Image objects are automatically downloaded by the browser, which is what causes the preloading.)

So change the inside of the for loop to this:

imglist[j] = new Image();
imglist[j].src = 'thumbs/thumb'+j+'.jpg';

Since I see you were confused about using the eval() function, I'm going to ask you to wipe the existance of it from your mind. You *rarely* need it. Extremely rarely. If you think you need it, you probably don't really. So until you advance a little more, never use it unless someone else tells you to... and even then, think hard about whether you really need to or not. =) Because it's already confusing you a little.

As for your zscrollbar problem, the problem is that zscrollbar uses the onload event handler, and when you set it in the body tag, you override the function that zscrollbar sets. Try adding this code after the zscrollbar include but before the body tag:

oldonload = new Function(onload);
onload = function() {oldonload(); WHATEVER YOU HAD IN THE BODY ONLOAD TAG GOES HERE };

I'm not sure that'll work, but it might.

anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-26-2002 18:11

slime, thx for quick response.
i forgot to add the second array in my code and you already responded when i edited so i dunno if you saw the second array. i guess i don't need the second array then if i compact the two.

ok i will go change the zscrollbars. thx again.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-26-2002 18:29

Oh, yeah, the new code you edited in should work fine.

anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-26-2002 19:01

i made it more compact and combined the two loops. i got the onLoad working. as long as i called the function before the setup for the zscrollbars, it worked =)

anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-31-2002 05:15

hi i'm having problems again, this time it's a crossbrowser problem. i got everything working fine in IE and finally got a hold of netscape to test (i'm on dialup). when i first ran it in netscape, everything was out of position & the zscrollbars didn't show up, but the rollover images were working. so i fixed my css and got everything lined up and scrollies to show in netscape but now the rollovers aren't working the weird part is i'm not getting any javascript errors. let me extend the code from the earlier post

code:
if (roll == 'true') {

var imglist = new Array();
imglist[0] = new Image();
imglist[0].src = "buttonover.gif";

for (var j=1; j<28; j++) {
imglist[j] = new Image();
imglist[j].src = 'thumbs/thumb'+j+'.jpg';
}
}

// rollover functions
function msover(img,ref) {
if (roll == 'true') {
document.images[img].src = ref;
}
}
function msout(img,ref) {
if (roll == 'true') {
document.images[img].src = ref;
}
}



then my buttons are coded as this:

code:
<div id="button1"><a href="about.htm" onMouseOut="msout('button','button.gif');" onMouseOver="msover('button','buttonover.gif');"><img name="button" border="0" src="button.gif"></a></div>



mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-31-2002 06:21

You didn't say which version of Netscape is giving you troubles...

If it's version 4, then you also need to specify layer that contains image that has to be replaced, like this:

document.layers["layerName"].document.images[img].src = ref;

It it's version 6, then the problem is probably located somewhere else and you should post a link to example page.

BTW You're checking if variable roll is a string with value "true" (and this will only work if you initialized as string too). Instead of using string I would suggest you to use boolean type.

// initialization
roll = true;

// simplified if statement
if (roll) {
}


anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-31-2002 09:27

ah those layers! ok, makes sense now. i was using netscape 4 (oh the headaches). i took your advice on the roll thing too. i also noticed my msover() and msout() were identical...oops. got rid of that redundancy too. i got a lot to learn. you guys have been really helpful. thx again.

« BackwardsOnwards »

Show Forum Drop Down Menu