Jump to content
xisto Community
icemarle

Rollover Question

Recommended Posts

You can save your self the burden of having to see these problems by inserting a preloading code in html page.

add this chunk of javascript to the <head</head> tags of your page:

<script language="javascript"><!--var myimages=new Array()function preloadimages(){for (i=0;i<preloadimages.arguments.length;i++){myimages[i]=new Image()myimages[i].src=preloadimages.arguments[i]}}preloadimages("image1.jpg","image2.jpg","image3.jpg","image4.jpg");//--></script>

replace image1.jpg to image4.jpg with the pictures that you are using, add more as prefered.

and replace
<body>

with this:

<body onload="preloadimages()">

by doing this, all your images will load before the site shows, so the on mouse over will automactically show up if you have a slow connection.

hope this will help,
-whyme

Share this post


Link to post
Share on other sites

Hold on whyme... I did it now, and well, I have to leave the cursor on the image for a while, and it still takes some time for it to change. (Despite making the image size/filesize smaller) Dooga, that's a cool site! *is mesmerized*The main problem is that it takes a long time for the swap image to show up. I wonder if I should leave a note for slower connections, or is there hope? Luckily I'm using Dial-up, so I can test it.

Share this post


Link to post
Share on other sites

Hmm, ultimately, I can only say that apparenetly, your connection is so slow that it will still take some time for the javascript itself to function. The only solution left is to use CSS and render it the same way. I'll do this for you if you want, and you can test it on your 56k connectionpm me later,-whyme

Share this post


Link to post
Share on other sites

What's CSS? Thanks for the help again! It's so nice of you! Yeah, my connection's slow. But at least it could help me test the site if it's friendly for slower connections. A lot of people still use slow connections you know.

Share this post


Link to post
Share on other sites

CSS is Cascading Style Sheets, it's another wat that you can do rollovers and create content layout without fumbling around with javascript. If you want to try out CSS, PM me, and i'll do it for you later this week, right now, I'm a bit busy with work.- whyme

Share this post


Link to post
Share on other sites

I see. I changed my script. It isn't DHTML anymore. It takes a second for the rollover to work in IE. (1 sec. of cursor over the image) But it doesn't work at all in Firefox. (For me) But it works in all browsers offline. Strange. I PMed you about this too. You haven't seemed to reply yet. I guess you're busy, but you should check out what I changed before you make scripts for me. Once again, Thank you for your time!

Share this post


Link to post
Share on other sites

Somebody beat me to the preload function -_- But I did notice what seemed to be several identical javascripts in your code. I don't have time to pour over your code, but here is my appraisal of the situation.You know that script that handles the function that switches images? You only need that once. You can reference that function as many times as you want in the body of your page, but inserting the script in the head multiple times only serves to slow everything down.Presumably, you put that in your code once for each image. Classic n00b. I did the same thing before I learned a bit about Javascript.Of course, it's entirely possible that I overlooked something in my haste (finals week!).

Share this post


Link to post
Share on other sites

Yes, it's true. I did put several scripts of that for each image. -_- I know nothing about Javascript, like I mentioned before, I'm afraid to tamper with it. So here I am waiting for someone to show me how to create a script that I can use for the entire page. (Or is it all I need? If I delete all but one of those head tag scripts, will it work?)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.