SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help debugging rollover Javascript

    This is the site: www.band-nation.co.uk/index.html

    This page uses a rollover code based on a cross-browser setup script served from an external document. It works fine on IE6 and AOL's viewer, but not on Netscape. Can anyone see an error in these popUp and popOff functions?


    <script type="text/javascript" language="Javascript">
    <!--
    function popUp(evt,currElem){
    if ((isNS4 && currElem !=0)||(isIE4 && currElem !=0)) {dom=eval(docObj+'.'+currElem+styleObj);
    {dom.visibility="visible";}
    }
    }
    -->
    </script>

    <script type="text/javascript" language="Javascript">
    <!--
    function popOff(evt,currElem){
    if ((isNS4 && currElem !=0)||(isIE4 && currElem !=0)){dom=eval(docObj+'.'+currElem+styleObj);
    {dom.visibility="hidden";}
    }
    }
    -->


    Any suggestions?
    Last edited by WiccaMan; Oct 20, 2001 at 14:57.

  2. #2
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I belive Netscape's DOM visibility attributes are listed as "SHOW" and "HIDE" as oppposed to "visibility" and "hidden".

    You might need a browser detection to set this up.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Moospot (great name!)
    I'm already using a browser detection script, but I can see that this won't allow the functions to work if the variables have different names, as you suggest. I shall try working that into the code. Thanks for the idea.

  4. #4
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad I could help

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, I still can't get it to work. Here's what I tried:

    <script type="text/javascript" language="Javascript">
    <!--
    function popUp(evt,currElem){
    if (isNS4 && currElem !=0){dom=eval(docObj+'.'+currElem+styleObj);{dom.visibility="show";}
    }
    else if (isIE4 && currElem !=0){dom=eval(docObj+'.'+currElem+styleObj);{dom.visibility="visible";}
    }
    }
    -->
    </script>

    isNS4 and isIE4 are variables set up in an external script which works fine on Explorer. But not in Netscape. What's wrong?

  6. #6
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For rollovers, I usually use dreamweaver's code. It may be ugly, but it works.

    Code:
    <script language="JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    The HTML part looks like this:

    Code:
    <a href="default.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image25','','/images/nav_home_over.gif',0)"><img name="Image25" border="0" src="/images/nav_home.gif" width="130" height="14"></a>

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, I misled you. The rollover script (for the little arrow pointers) works fine. The script above is for a popup menu box. If you view my site in Explorer, you'll see what's supposed to happen.

    Thanks anyway for the suggestion.

  8. #8
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't seem to get your page up right now.. I will check with both browsers in a few

  9. #9
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow! I don't know if you've been working on it or not, but NS sure doesn't like your code.

    Try looking here for some cool DHTML stuff

    http://www.dhtmlcentral.com/index.asp

  10. #10
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's up? What do you see? Viewed locally, Netscape 6 displays everything correctly except for this particular code (at least, on my computer). Which version of NS are you using?

    Thanks for the link.

  11. #11
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  12. #12
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bugger.
    I even tried it on AOL and it looks fine. What should I do?

  13. #13
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, NS 4 never was good for much and fewer than 5% of my visitors even use it, so I say forget optimizing it for NS and leave it the way it is.

    You can always setup a more "browser-friendly" version for your non-IE users with a detect/redirect.

    Check your web logs and see how many people are actually using NS to visit your site. Then make a decision.

  14. #14
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Moospot. I'm inclined to agree with everything you say. Regarding checking the web logs, is that easy to do?

  15. #15
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ask your webhost. They should have something set up, I hope). You might want to look into web log analyzers (like WebTrends).

    Our statistics on browser usage are about average in the industry though. There was a thread about that very subject, though I can't seem to find it


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •