Hiding CSS class from Netscape 4.x

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TravelMan

    Hiding CSS class from Netscape 4.x

    I'm trying to do a show/hide of several elements on a page and can't
    get it working in Netscape 4.x. All other Windows browsers are
    working.

    My elements all have the same class name. <div
    class="myClassN ame">stuff</div>
    I cannot use ID because I don't know how many will appear as they are
    dynamic recordsets. Netscape seems to work OK with IDs but not CSS
    classes.

    For Netscape 4.x I have coded in my JavaScript:
    document.myClas sName.visibilit y = "hide"; to hide it and
    document.myClas sName.visibilit y = "show"; to show it.

    My CSS for this function is:

    <style type="text/css">
    ..myClassName {visibility:hid den;}
    </style>

    When I use the toggle I get this error: document.myClas sName has no
    properties.

    Any suggestions? Right now we are considering having standards-aware
    browsers use client-side show/hide ( via
    document.getEle mentsByTagName( ) ) and forcing Netscape 4.x to reload
    the page, but would prefer to do it all in the browser.
  • kayodeok

    #2
    Re: Hiding CSS class from Netscape 4.x

    travel-man@excite.com (TravelMan) wrote in
    news:ca0c0fd6.0 310141307.7e9db c38@posting.goo gle.com:
    [color=blue]
    > I'm trying to do a show/hide of several elements on a page and
    > can't get it working in Netscape 4.x. All other Windows browsers
    > are working.
    >[/color]

    Why not hide all CSS from Netscape 4.x and provide Structural Markup?
    You can't support buggy browsers for ever...

    How to hide CSS from buggy browsers


    --
    Kayode Okeyode

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: Hiding CSS class from Netscape 4.x

      TravelMan wrote:[color=blue]
      > I'm trying to do a show/hide of several elements on a page and can't
      > get it working in Netscape 4.x. All other Windows browsers are
      > working.[/color]

      Sorry, but I really doubt that the below is working with *any* user agent.
      [color=blue]
      > For Netscape 4.x I have coded in my JavaScript:
      > document.myClas sName.visibilit y = "hide"; to hide it and
      > document.myClas sName.visibilit y = "show"; to show it.
      >
      > My CSS for this function is:
      >
      > <style type="text/css">
      > ..myClassName {visibility:hid den;}[/color]

      Is the `..' a typo? If not, remove one dot.
      [color=blue]
      > </style>
      >
      > When I use the toggle I get this error: document.myClas sName has no
      > properties.[/color]

      You cannot reference CSS classes like objects. Instead, iterate
      through the collection of DIV elements (use document.getEle mentsByName,
      document.getEle mentsByTagName or document.layers , depending on the DOM[1])
      and change the `className' property of each element to the name of a
      CSS class where the `visibility' property has the value of `show'.


      F'up2 cljs

      PointedEars
      ___________
      [1] Possibly you find http://pointedears.de.vu/scripts/dhtml.js useful
      in this regard.

      Comment

      • e n | c k m a

        #4
        Re: Hiding CSS class from Netscape 4.x

        > and change the `className' property of each element to the name of a[color=blue]
        > CSS class where the `visibility' property has the value of `show'.[/color]

        Why is that better than using JavaScript to change the CSS property?
        I'm just curious because I saw that method elsewhere [on the MSDN] and found
        it quite interesting. Is it really better? You're still using JavaScript
        either way.

        Thanks,
        Nicko.


        Comment

        • Martin Honnen

          #5
          Re: Hiding CSS class from Netscape 4.x



          TravelMan wrote:
          [color=blue]
          > I'm trying to do a show/hide of several elements on a page and can't
          > get it working in Netscape 4.x. All other Windows browsers are
          > working.
          >
          > My elements all have the same class name. <div
          > class="myClassN ame">stuff</div>
          > I cannot use ID because I don't know how many will appear as they are
          > dynamic recordsets. Netscape seems to work OK with IDs but not CSS
          > classes.
          >
          > For Netscape 4.x I have coded in my JavaScript:
          > document.myClas sName.visibilit y = "hide"; to hide it and
          > document.myClas sName.visibilit y = "show"; to show it.
          >
          > My CSS for this function is:
          >
          > <style type="text/css">
          > .myClassName {visibility:hid den;}
          > </style>
          >
          > When I use the toggle I get this error: document.myClas sName has no
          > properties.
          >
          > Any suggestions? Right now we are considering having standards-aware
          > browsers use client-side show/hide ( via
          > document.getEle mentsByTagName( ) ) and forcing Netscape 4.x to reload
          > the page, but would prefer to do it all in the browser.[/color]

          Are those <div> elements positioned absolutely or statically with CSS?
          If not forget about manipulating them with script as NN4 only makes
          positioned elements available in its DOM.
          If the <div>s are positioned then they should appear in
          document.layers
          and you can loop through document.layers
          for (var i = 0; i < document.layers .length; i++)
          document.layers[i].visibility = 'hide';
          However if you wanted to check the class attribute of such a layer you
          can't so you need to use other means to identify that a layer belongs to
          a class, some way is to use an id attribute of the form
          <div id="myClass01" >
          then you can check
          document.layers[i].id.indexOf('my Class') == 0
          to find out whether a layer belongs to your class.

          Of course it is doubtful whether Netscape 4 is still worth the efforts,
          some static functioning HTML page should suffice for Netscape 4 users.
          --

          Martin Honnen


          Comment

          • TravelMan

            #6
            Re: Hiding CSS class from Netscape 4.x

            Thomas 'PointedEars' Lahn <PointedEars@we b.de> wrote in message news:<3F8C6DC7. 5040803@Pointed Ears.de>...[color=blue]
            > TravelMan wrote:[color=green]
            > > I'm trying to do a show/hide of several elements on a page and can't
            > > get it working in Netscape 4.x. All other Windows browsers are
            > > working.[/color]
            >
            > Sorry, but I really doubt that the below is working with *any* user agent.
            >[color=green]
            > > For Netscape 4.x I have coded in my JavaScript:
            > > document.myClas sName.visibilit y = "hide"; to hide it and
            > > document.myClas sName.visibilit y = "show"; to show it.
            > >
            > > My CSS for this function is:
            > >
            > > <style type="text/css">
            > > ..myClassName {visibility:hid den;}[/color]
            >
            > Is the `..' a typo? If not, remove one dot.
            >[color=green]
            > > </style>
            > >
            > > When I use the toggle I get this error: document.myClas sName has no
            > > properties.[/color]
            >
            > You cannot reference CSS classes like objects. Instead, iterate
            > through the collection of DIV elements (use document.getEle mentsByName,
            > document.getEle mentsByTagName or document.layers , depending on the DOM[1])
            > and change the `className' property of each element to the name of a
            > CSS class where the `visibility' property has the value of `show'.
            >
            >
            > F'up2 cljs
            >
            > PointedEars
            > ___________
            > [1] Possibly you find http://pointedears.de.vu/scripts/dhtml.js useful
            > in this regard.[/color]

            How do you get a handle on the className for a DIV when
            getElementsByTa gName doesn't work in NN4.x? Is there another way to
            get the className for a DIV or a layer?

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: Hiding CSS class from Netscape 4.x

              TravelMan wrote:
              [color=blue]
              > Thomas 'PointedEars' Lahn <PointedEars@we b.de> wrote in message
              > news:<3F8C6DC7. 5040803@Pointed Ears.de>...[/color]

              It is called attribution _line_.
              [color=blue][color=green]
              >> TravelMan wrote:
              >> [...][color=darkred]
              >> > <style type="text/css">
              >> > ..myClassName {visibility:hid den;}[/color]
              >>
              >> Is the `..' a typo? If not, remove one dot.
              >>[color=darkred]
              >> > </style>
              >> >
              >> > When I use the toggle I get this error: document.myClas sName has no
              >> > properties.[/color]
              >>
              >> You cannot reference CSS classes like objects. Instead, iterate
              >> through the collection of DIV elements (use document.getEle mentsByName,
              >> document.getEle mentsByTagName or document.layers , depending on the DOM[1])[/color][/color]
              ^^^^^^^^^^^^^^^[color=blue][color=green]
              >> and change the `className' property of each element to the name of a
              >> CSS class where the `visibility' property has the value of `show'.
              >> [...][/color]
              >
              > How do you get a handle on the className for a DIV when
              > getElementsByTa gName doesn't work in NN4.x?[/color]

              See above. The document.layers[...] collection allows for referencing
              positioned layers.
              [color=blue]
              > Is there another way to get the className for a DIV or a layer?[/color]

              Sorry, NS4-DOM seems not to provide a className property,
              so referenceToLaye r.visibility is the only way.


              (again!) followup-to comp.lang.javas cript

              PointedEars

              P.S.: Please don't quote what you are not referring to.

              Comment

              • TravelMan

                #8
                Re: Hiding CSS class from Netscape 4.x

                Can you recommend any good books on the DOM and DOM scripting? I'm new
                to using that and already am impressed by the power of what it offers.
                Thanks.

                Comment

                • William Tasso

                  #9
                  Re: Hiding CSS class from Netscape 4.x

                  TravelMan wrote:[color=blue]
                  > Can you recommend any good books on the DOM and DOM scripting?[/color]

                  follow from here: http://www.w3.org/DOM/
                  [color=blue]
                  > I'm new
                  > to using that and already am impressed by the power of what it offers.[/color]

                  just be sure you ensure your pages work in UAs without script support e.g.
                  googlebot.

                  --
                  William Tasso - http://WilliamTasso.com


                  Comment

                  Working...