Show and hide divs in FireFox

Discussion in 'Javascript' started by JonBosker@Yahoo.com, Mar 13, 2007.

  1. Guest

    Hi I have a little script that works well in IE but not in FireFox

    function DivExpand(obj, setting)
    {
    if ((setting == 'hide') || ((setting == 'swap') &&
    (document.all[obj].style.display == 'block')))
    document.all[obj].style.display = 'none';
    else
    document.all[obj].style.display = 'block';
    }

    can anyone please tell me what I have to change for FireFox?

    And would this test do the trick?
    var ns4 = (document.layers) ? true : false;
    var ie4 = (document.all && !document.getElementById) ? true : false;
    var ie5 = (document.all && document.getElementById) ? true : false;
    var ns6 = (!document.all && document.getElementById) ? true : false;

    Thanks in advance. Jon.
    , Mar 13, 2007
    #1
    1. Advertising

  2. -Lost Guest

    <> wrote in message
    news:...
    > Hi I have a little script that works well in IE but not in FireFox
    >
    > function DivExpand(obj, setting)
    > {
    > if ((setting == 'hide') || ((setting == 'swap') &&
    > (document.all[obj].style.display == 'block')))
    > document.all[obj].style.display = 'none';
    > else
    > document.all[obj].style.display = 'block';
    > }
    >
    > can anyone please tell me what I have to change for FireFox?


    document.getElementById(obj).style.display

    > And would this test do the trick?
    > var ns4 = (document.layers) ? true : false;
    > var ie4 = (document.all && !document.getElementById) ? true : false;
    > var ie5 = (document.all && document.getElementById) ? true : false;
    > var ns6 = (!document.all && document.getElementById) ? true : false;


    You should *never* browser detect. Instead, those variables should reflect levels of
    functionality. Or simply, feature detect as you go along.

    -Lost
    -Lost, Mar 13, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. middletree
    Replies:
    0
    Views:
    582
    middletree
    Oct 25, 2005
  2. Mike P
    Replies:
    7
    Views:
    901
  3. Mike P

    show/hide divs on checkbox click

    Mike P, Nov 14, 2007, in forum: ASP General
    Replies:
    1
    Views:
    235
    Dooza
    Nov 14, 2007
  4. Frances
    Replies:
    3
    Views:
    99
    Randy Webb
    Sep 9, 2005
  5. ll
    Replies:
    2
    Views:
    626
    Thomas 'PointedEars' Lahn
    May 1, 2008
Loading...

Share This Page