Clickable Rollover Image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor Matthews
    Senior Member
    • Oct 2010
    • 537
    • 4.1.x

    [CMS] Clickable Rollover Image

    Hi

    I want to create a Widget that basically displays an image of a magazine cover and when the mouse is rolled over the image it changes to another months cover. Clickable to take the user to the section of the forum that holds the magazines.

    I found this Javascript.....

    Code:
    <SCRIPT TYPE="text/javascript">
    <!--
    // copyright 1999 Idocs, Inc. [URL]http://www.idocs.com/tags/[/URL]
    // Distribute this script freely, but please keep this 
    // notice with the code.
    var rollOverArr=new Array();
    function setrollover(OverImgSrc,pageImageName)
    {
    if (! document.images)return;
    if (pageImageName == null)
        pageImageName = document.images[document.images.length-1].name;
    rollOverArr[pageImageName]=new Object;
    rollOverArr[pageImageName].overImg = new Image;
    rollOverArr[pageImageName].overImg.src=OverImgSrc;
    }
    function rollover(pageImageName)
    {
    if (! document.images)return;
    if (! rollOverArr[pageImageName])return;
    if (! rollOverArr[pageImageName].outImg)
        {
        rollOverArr[pageImageName].outImg = new Image;
        rollOverArr[pageImageName].outImg.src = document.images[pageImageName].src;
        }
    document.images[pageImageName].src=rollOverArr[pageImageName].overImg.src;
    }
    function rollout(pageImageName)
    {
    if (! document.images)return;
    if (! rollOverArr[pageImageName])return;
    document.images[pageImageName].src=rollOverArr[pageImageName].outImg.src;
    }
    //-->
    </SCRIPT>
    
    <A 
        HREF="rollover_target.html"
        onMouseOver = "rollover('home')" 
        onMouseOut  = "rollout('home')" 
        ><IMG 
        SRC="/images/misc/home_out.png" 
        NAME="home" 
        ALT="Home Page" BORDER=0 
        HEIGHT=130 WIDTH=115
        ></A>
    <SCRIPT TYPE="text/javascript">
    <!--
    setrollover("/images/misc/home_over.png");
    //-->
    </SCRIPT>

    I have created the two images and put them in the misc folder, named correctly.
    I selected the Static HTML choice from the New Widget option.
    This doesn't work.

    Is this just not possible using a widget or have I selected the wrong Widget option.

    Is there an easier way to achieve this or any suggestions please.
    Regards
    Trevor
  • Lynne
    Former vBulletin Support
    • Oct 2004
    • 26255

    #2
    It works just fine on my site when I make sure the image path is correct. /images/misc/etc is not the correct path for me since that is relative to the site root. I needed to change it to just images/misc/etc

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to vbulletin.org
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools &lt;- awesome site for html/css help

    Comment

    • Trevor Matthews
      Senior Member
      • Oct 2010
      • 537
      • 4.1.x

      #3
      Many thanks. I will try again.
      Regards
      Trevor

      Comment

      • Trevor Matthews
        Senior Member
        • Oct 2010
        • 537
        • 4.1.x

        #4
        Great, problem solved. GIMP was adding a funny file extension despite me saving them as .png.

        All working now.
        Regards
        Trevor

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎