"Matt" <matthew.crouch@spamlessverizon.net> wrote
> i know more-or-less zero about javascript, but my client wants a
> rollover and he created this code, which doesn't work. All comments are
> appreciated.
>
> 1. the tag:
> <td align="center" width="66" nowrap="nowrap"
> background="/work/phc1.10/images/layout/main_nav_bg.gif">
> <a href="http://localhost/work/phc1.10/index.php?page=homecare"
> onmouseover="imgSwap('','gnav_hc_on','gnav_hc_on')"
> onmouseout="imgSwap('','gnav_hc_off','gnav_hc_off')">
> <img name="gnav_hc_off"
> src="/work/phc1.10/images/layout/gnav/gnav_hc_off.gif" border="0"
> alt="Homecare" width="66" height="14" /></a>
> </td>
>
>
> 2. the function:
>
> function imgSwap(layer,imgName,imgObj) {
> var layer;
> var imgName;
> var imgObj;
> glayer = layer;
> gimgName = imgName;
> gimgObj = imgObj;
> if(document.images) {
> //NN 4.x DOM
> if(document.layers && layer != "") {
> eval('document.' + layer + '.document.images["' + imgName + '"].src =
> ' + imgObj + '.src');
> }
> //NN6 Gecko subroutine
> else if((objClient.application == "nn") && (objClient.version >= 5)) {
> imgSwapTimeOut();
> }
> else {
> document.images[imgName].src = eval(imgObj + ".src");
> }
> }
> }
> //NN Gecko subroutine
> function imgSwapTimeOut() {
> document.images[gimgName].src = eval(gimgObj + ".src");
> }
There are probably a million better written / less complex rollover scripts
out there, do you really need to use this one? If so, for starters, he
hasn't
set any image src's.
Secondly, the mouseover imgSwap('','gnav_hc_on','gnav_hc_on')"
should likely be imgSwap('','gnav_hc_off','gnav_hc_on')" since there is no
image named 'gnav_hc_on'.
If this is for a single rollover, (or perhaps in any case) junk the script,
not worth the trouble. Not to mention the <td> tag.
-alu
Received on Tue Oct 18 02:57:49 2005