We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14779
    • 256 Posts
    I wasn’t sure if I should post this here, or in the Wayfinder forum. I think I have wayfinder working, so this is probably a JS issue.

    Here is the situation:

    I am using wayfinder to generate a nav menu composed of images. I need the text to be a different color when hovering with the mouse, and when you are viewing the associated page. I have everything except the mouseover working. Here is my code:

    Wayfinder call:
    [!Wayfinder? &startId=`0` &rowTpl=`BGnavTPL` &hereTpl=`BGnavHERETPL` &jsTpl=`BGnavJS`  !] 


    BGnavJS chunk:
    <!-- START IMAGE ROLLOVER SCRIPT  ******************-->
    <SCRIPT TYPE="text/javascript">
    <!--
    // copyright 1999 Idocs, Inc. http://www.idocs.com/tags/
    // 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>
    
    <!-- END IMAGE ROLLOVER SCRIPT  ********************************-->


    BGnavTPL wayfinder row template:
    <li><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+] onmouseover = "rollover('[+wf.title+]')" onmouseout  = "rollout('[+wf.title+]')"><img src="/assets/images/navigation/[+wf.title+].gif" alt="[+wf.title+]" name="[+wf.title+]" /></a><script type="text/javascript"><!--setrollover("/assets/images/navigation/[+wf.title+]_blue.gif"); //--></script>[+wf.wrapper+]</li>


    BGnavHERETPL wayfinder HERE row template:
    <li><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]><img src="/assets/images/navigation/[+wf.linktext+]_pink.gif" alt="[+wf.title+]" /></a>[+wf.wrapper+]</li>


    All the images are in the correct location, and looking at the source code it seems like it should work.
    Here is a link to the page:
    http://s163069307.onlinehome.us

    Can anyone please help me figure out why this doesn’t work?
    The link to the js page is: http://www.htmlcodetutorial.com/images/images_famsupp_59.html
      PM me to find out how you can get a FREE ipad 2!
      • 14779
      • 256 Posts
      Does Someone have a clue as to why this might not be working?
        PM me to find out how you can get a FREE ipad 2!
        • 27708 MODX Staff
        • 2,502 Posts
        This JS method is very old. I am not 100% sure why it is not working. If I ever do an image based nav I use CSS Sprites and image replacement as it is faster and more browser compatible.

        That being said. If you are using a fixed navigation structure there is no reason in the world to use wayfinder. Just create your list in HTML and use the id of the page as the url like [~15~] for page 15.

        You may have far more luck debugging if Wayfinder is not in the mix. Wayfinder only makes sense if you are using it to control the output of the menu, since this is not the case go with a hardcoded menu in a chunk or template.

        Cheers,

        Jay
          Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
          • 14779
          • 256 Posts
          Thanks for taking a look at this Jay!
          If there a resource you can recommend to me for getting this done via CSS?
            PM me to find out how you can get a FREE ipad 2!
            • 14779
            • 256 Posts
            I solved the problem by eliminating wayfinder, using a static HTML UL menu in a chunk, and using the CSS techniques described here:
            http://alanwho.com/css/rollover-css-image-menu/
              PM me to find out how you can get a FREE ipad 2!
              • 27708 MODX Staff
              • 2,502 Posts
              Glad it all worked for you. I was out last night but it was likely better you got to figure it out on your own anyhow.

              Looks good.

              Cheers,

              Jay
                Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
                • 5950
                • 44 Posts
                *resurrects*

                I am trying to use the exact same JS code to work image rollovers into wayfinder.

                I would be happy to use CSS for the menu, but I have powers-that-be who like to print pages for review, and directions to ’toggle on your background images when you print’ isn’t really something they want to hear.

                So whether I use this javascript or another method, I need an image rollover that works with Wayfinder which will set an image in the ’foreground’ of the document.

                I would greatly appreciate some help with the code shown above, or any other ideas for doing this.