iWeb Tip #13 – Rollovers in iWeb
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—https://web.me.com/username/rollover_images/rollover.jpg or if you using your own host it would be —https://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 ="https://web.me.com/username/rollover_images/rollover.jpg"}
function mouseOut()
{document.rollover_one.src ="https://web.me.com/username/rollover_images/normal.jpg"}
</script>
<a href="https://www.your_button_link_here.com">
<img alt="Link Title" src="https://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="https://www.iwebunlimited.com">
with
<a href="https://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…
Add WHAT?
Yeah, what?! I have the same “sticky” rollover issues. They seem to have a life of their own! When I publish and go check the rollovers they don’t light up right away and then they stick until I roll over them again. Nothing like what the tute showed.
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.
Ok, so when the page first comes up the images aren’t there. Just a ? Mark. Once you rollover them, THEN they show up. Also, there’s a blue line under the rollover. Anyone have any ideas? I saw a post where someone says there’s a way to preload the images but he doesn’t say how. Help!
Hi, this is great site. I am probably doing something wrong. I follow step by step the as describe, replacing URLs and picture names. When clicking apply, the widget changes to the defined size, but instead of the picture only question mark in blue square appears. When clicking the box, defined link works. Please advice.
I am working on the rollovers. I can get them to work on my home page fine – Publish check it out and all is good!
Then, I copy paste my nav bar to all my pages, Publish, and the links/rollovers are going crazy on all the pages except the Home Page. Do I need to rewrite the code for every page? Is copy pasting the snippets across pages not going to work?
I do have the site password protected. Could that be affecting the ability to load the correct/rollover images for the navbar?
I don’t want to not password protect the site until it is completed. Please let me know if anyone has come across this.
Thanks,
Adam
It was the password messing it up!
Now – Does anyone know how to get .png or .gif rollovers to work in IE????
PLEASE HELP WITH THIS ONE> All my clients use IE (what are they thinking?)
Hi there, this website is proving invaluable.
I too was experiencing the question mark etc but found that this code resolved the issue:
Ok… my code didn’t seem to come up there(?) How do I post code?
Hi,
I’m trying to create buttons with rollovers but when I add the HTML snippet to the area I want the button, a line appears at the bottom of the box. I just doesn’t disappear even when I add the graphic. Does anyone know what is going on? I’m using the code from this site and the button graphic appears and works fine with both up and over states just has this weird line. Driving me crazy!
Hi there… thanks for the tutorial… It´s very helpful…. but I have a problem…. It appears underlined with a blue line down….
Do you know what can I do?
http://www.ceroyunodigital.com/ceroyuno/new_york.html
Thanks in advance…
Nicolas
These tutorials are very helpful! I’m trying to create a specific type of menu for a friend that I’m not entirely sure is possible in iWeb.
I have a left hand vertical menu and I want to rollover the text to reveal a “dropdown” menu to the right, but I want the rollover menu to only be text, with no box around it. It should lay over my graphics so they’re still visible even when the menu is active.
Possible?? If not, is it possible to create a “drop across” menu to the right, instead of down?
Pardon my inexperience, but will I have to enter the snippet code every time I publish updates on the website? I have deadline this next week so a quick response would be appreciated! Thank you!
Does this work with shadows and reflection?