iWeb Tip #13 – Rollovers in iWeb

70
18065

Rollovers in iWebIt’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">

70 comments

  1. Mike Oliver 15 February, 2010 at 18:10 Reply

    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?

  2. ryan 12 March, 2010 at 18:55 Reply

    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

  3. Lane 18 March, 2010 at 18:46 Reply

    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!

  4. Bren 22 March, 2010 at 08:52 Reply

    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?

    • Adam 28 March, 2010 at 02:30 Reply

      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

  5. Chad 19 April, 2010 at 22:22 Reply

    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/

  6. dave 25 April, 2010 at 14:34 Reply

    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!

    • dave 25 April, 2010 at 15:54 Reply

      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…

  7. dave 25 April, 2010 at 16:47 Reply

    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

    • Dill 16 May, 2010 at 06:51 Reply

      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?

  8. mike 27 April, 2010 at 09:08 Reply

    Amazing site ! does anyone know how to deal with the white flashes that show just before the rollover widget loads up ?

    thanks!

    • iWebUnlimited 29 April, 2010 at 10:00 Reply

      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.

  9. Daniel 9 May, 2010 at 06:19 Reply

    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. :)

  10. kyle 18 May, 2010 at 07:14 Reply

    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.

  11. Justin 7 September, 2010 at 15:58 Reply

    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.

  12. BigTimeProductions 17 September, 2010 at 01:36 Reply

    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!

  13. Eduard 21 September, 2010 at 16:35 Reply

    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.

  14. Adam 6 October, 2010 at 10:05 Reply

    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

    • Adam 7 October, 2010 at 14:10 Reply

      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?)

  15. thecolourinbetween 9 October, 2010 at 07:09 Reply

    Hi there, this website is proving invaluable.
    I too was experiencing the question mark etc but found that this code resolved the issue:

  16. Bando 19 October, 2010 at 02:20 Reply

    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!

  17. Christina 21 October, 2010 at 17:43 Reply

    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?

  18. R. Willis 29 October, 2010 at 20:18 Reply

    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!

Leave a reply

Recommended

Facebook
Twitter
YouTube