It’s always fun to add some user interaction to your website and currently the only rollover like interaction iWeb gives us is text rollovers as links. Well this post is to show you how to get image rollovers on your iWebsites. Here we go:
See Demo
Step 1) Make 2 graphics. One that is the up/normal state, or what you want to be up when the users mouse is not over the image. Then make the other graphic the rollover state or what the graphic will look like when you roll the mouse over it.
Step 2) Size those 2 graphics as small as you can get them without losing quality. Photoshops save for web features works good for this, but you can get this effect just as easy by opening it with Preview and saving as jpeg and adjusting the quality.
Step 3) Put those 2 graphics on your server. You can use the iDisk with MobileMe or your own server. Just make a folder somewhere on the server perhaps call it “rollover_images” or something like that. If your putting it on MobileMe make the folder in this location: iDisk/Web/Sites/rollover_images . Then the URL to the images will look something like this: For MobileMe—http://web.me.com/username/rollover_images/rollover.jpg or if you using your own host it would be —http://www.yoursite.com/rollover_images/rollover.jpg in which you would put the folder right on the root level of your public server.
Step 4) Then simply copy the code below and paste into a snippet.
<script type="text/javascript"> function mouseOver()
{document.rollover_one.src ="http://web.me.com/username/rollover_images/rollover.jpg"}
function mouseOut()
{document.rollover_one.src ="http://web.me.com/username/rollover_images/normal.jpg"}
</script>
<a href="http://www.your_button_link_here.com">
<img alt="Link Title" src="http://web.me.com/username/rollover_images/normal.jpg" name="rollover_one" width="175" height="175" onmouseover="mouseOver()" onmouseout="mouseOut()" style="border: none;"/></a>
Step 5) Replace what’s in red with your URL’s to your images and image sizes and put in what link you want it to go to by replacing the iwebunlimited link and your set.
Note: If you’d like the link to open in a new page replace the link
<a href="http://www.iwebunlimited.com">
with
<a href="http://www.iwebunlimited.com" target="_blank">













First I want to say this site, your videos, and blogs have been so helpful!!!!
For whatever reason I cannot seem to get the rollovers correct. I am positive it is in my coding. Do I need to use a user name with godaddy?
Hi there, thanks for that. If possible i’d really appreciate if you could do a tute on how to code css sprite menus. Similar outcome as above but with one image.
cheers,
Ryan
Thank you for the tip… it seems to be working when looked at in Safari, but not in Firefox (in Firefox it shows a box with a “?”) …. any ideas?
Thanks!
same problem… I too think it is in the coding? I also am using godaddy… do we need to put something different? I have tried using the http mobile me address and the http://www.mysite.com address both leave me with an empty text box and ?…. been working on it for days… always the same result? We must be missing something obvious?! Anyone able to get it to work?
I’m having the same problems as you, using godaddy and can’t seem to work this one out, is there anyway to place a dynamic url instead of the static one? or anything that will get it to work?
Awesome website, thanks a lot for the info.
Adam
This tip works great with .png and .gif as well if transparency needs to be preserved.
Excellent resource. I’m having a problem, though, with the “normal” state buttons. I have 5 buttons, with 5 sliced PNGs for normal and 5 sliced PNGs for the rollover. The rollovers work fine. The normal always shows the same PNG (up_05.png) regardless of what I put in the snippet or even if I change the names – it always shows that one. If I take it out of the directory, I get an “?”, but the rollover image still works perfect. Any thoughts? Here’s the site: http://www.designitsweet.com/pinecrest/
Scratch that. Got it.
hi – thanks so much for these tips – they are amazingly simple to follow – i’ve made a bunch off rollovers using 10kb jpg images – they are pretty slow to load when you hover your mouse over the image – do i need a faster ftp server or is there a simple way to cache (preload) the images ?
thanks for any help!
hey guys – managed to answer my own question – simply add this to the top of the code and the images are preloaded – you need to edit the url and image size…
here’s the link – http://www.yourhtmlsource.com/images/preloading.html
Hi – sorry for all the posts – does anyone know how to combine rollovers with highslide? so that the rollover button opens as a popup – the popup opens within the widget rather than in the main window…
any help much appreciated
ijason, you are brilliant, so glad people like you are out there, what a good site! I’m in the process of following your tips and building a new site for myself, so I will be making a donation when I’m done. In the meantime I have the same question as Dave. I would really like to use Highslide with rollover images, is there a way?
Amazing site ! does anyone know how to deal with the white flashes that show just before the rollover widget loads up ?
thanks!
Mike, many times that’s the 2nd image loading in. You can sometime get away from that by getting your images sized very small. There might be a way we could find some code that loads both images at once so that the rollover is a little more smooth, I’ll have to play with some code, if I get it I’ll post it.
Excellent – Thanks!
Hi
I got 3 rollovers on 1 page – in Safari it works just fine, but in Firefox and IE it only loads 1 of the rollovers.
Take a look: http://www.byfred.com/bf/contactdk.html – it’s only the twitter icon that loads.
Whats wrong? Please help me :-)
Thanks,
Frederik
Great tip Thanks a million. But is there any easy way to get the image to fade from one to another when i you rollover it. I really need to know thanks. :)
Good day sir.
function mouseOver()
{document.rollover_one.src =”http://greentagclothing.com/images/mu.png”}
function mouseOut()
{document.rollover_one.src =”http://greentagclothing.com/images/mo.png”}
i have a problem with implementing this one. IM not using mobile me, so I gues it would look something like this. But it didn’t work. Do I have put in the server before it works?
2nd question:
I tried using the lytebox and highslide it works perfectly but how do you keep them working even if you publish something. The tendency is when you even just click your page in iweb, it usually goes “red” meaning it’s touched and has to be republished again (which will change again the html)
thank you MORE POWER to this site.
the roll over is working :D, need help i gues for the 2nd question only.
Anybody figure out how to get rollovers working with a shadow box link. I’ve been futzing with the code for a couple hours to no avail.