DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: help NN6 and DHTML popup menu

  1. #1
    rick schaefer Guest

    help NN6 and DHTML popup menu


    I was recently assigned a DHTML fix at work. While I know html pretty well
    and a little javascript I am out of my league here. Any help people could
    provide would be great. The deadline is approaching and I am getting worried
    about figureing it out.

    I was asked to make a DHTML pop-up menu work in Netscape 6. I didn't write
    the original code and understand it only on a basic level. I have spent the
    last week playing around with it trying to make it work. I understand that
    Netscape 6 uses a different DOM than either NN4 or IE. I also realize that
    I probably need to use getElementById() but I am confused about the syntax.
    I am using a showHide function to change a hidden layer's state to visible
    from hidden. I have created a document sniffer to pick out the netscape
    6 browser but don't know how to make it switch.

    I have provided the code that we were using originally that works for IE
    and NN4, as well as a sample of what I am playing around with now. I would
    greatly appreciate any help I can get. Thanks.

    The code I started with:

    the 2 functions

    function showHide() { //v2.0
    var i, visStr, args, theObj;
    args = showHide.arguments;
    for (i=0; i<(args.length-2); i+=3) { //with arg triples (objNS,objIE,visStr)
    visStr = args[i+2];
    if (navigator.appName == 'Netscape' && document.layers != null) {
    theObj = eval(args[i]);
    if (theObj) theObj.visibility = visStr;
    } else if (document.all != null) { //IE
    if (visStr == 'show') visStr = 'visible'; //convert vals
    if (visStr == 'hide') visStr = 'hidden';
    theObj = eval(args[i+1]);
    if (theObj) theObj.style.visibility = visStr;
    } }
    }

    function resetAll() {
    showHide('document.layers[\'ddCatagory1\']','document.all[\'ddCatagory1\']','hide');
    showHide('document.layers[\'ddCatagory2\']','document.all[\'ddCatagory2\']','hide');
    }

    the links that trigger it:
    <a href="comingsoon.html"
    onmouseover="resetAll(); resetPopOuts(); changeImages('leftnav_04', '../images/leftnav_04-over.gif');
    showHide('document.layers[\'ddCatagory1\']','document.all[\'ddCatagory1\']','show');
    return true;">
    <img name="leftnav_04" src="../images/leftnav_04.gif" width="159" height="20"
    border="0"></a>

    <a href="#"
    onmouseover="resetAll(); resetPopOuts(); changeImages('leftnav_05', '../images/leftnav_05-over.gif');
    showHide('document.layers[\'ddCatagory2\']','document.all[\'ddCatagory2\']','show');
    return true;">
    <img name="leftnav_05" src="../images/leftnav_05.gif" width="159" height="20"
    border="0"></a>

    So I have modified the the first function as follows:

    function showHide() { //v2.0
    var i, visStr, args, theObj;
    args = showHide.arguments;
    for (i=0; i<(args.length-2); i+=3) { //with arg triples (objNS,objIE,visStr)
    visStr = args[i+2];
    if (navigator.appName == 'Netscape' && navigator.appVersion <= '5.0'
    && document.layers != null) { //NN4
    theObj = eval(args[i]);
    if (theObj) theObj.visibility = visStr;
    }if (navigator.appName == 'Netscape' && navigator.appVersion <= '6.0'
    && document.getElementById != null) { //NN6
    theObj = eval(args[i]);
    if (theObj) theObj.getElementById = visStr;
    } else if (navigator.appName == 'Microsoft Internet Explorer' && document.all
    != null) { //IE
    if (visStr == 'show') visStr = 'visible'; //convert vals
    if (visStr == 'hide') visStr = 'hidden';
    theObj = eval(args[i+1]);
    if (theObj) theObj.style.visibility = visStr;
    } }
    }


    I have assigned an ID="ddCatagory1" and ID="ddCatagory2" respectively to
    the divs that need to be shown.

    I have tried all sorts of things in the netscape 6 section but nothing i
    have done has worked. I also don't know the syntax for that to put in the
    showHide() statement.

    Thanks again for any help in advance. If you need any more information please
    ask.

  2. #2
    matt cow Guest

    Re: help NN6 and DHTML popup menu


    sorry you had to wait for a bit, only found out about this newsgroup today

    you should make navigator.appVersion return a number only (it returns more
    than just a number) and compare against that:

    not:
    navigator.appVersion <= '5.0'
    but:
    parseFloat(navigator.appVersion)<= 5.0

    better still, for versions upto 6:
    parseFloat(navigator.appVersion)< 6.0
    and for 6 and above:
    parseFloat(navigator.appVersion)>= 6.0

    good luck,
    matt cow


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center