problem with style.display="none" in NN7

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

    problem with style.display="none" in NN7

    Hi,

    I have a section of a web page that I want to be able to make appear and
    disappear with javascript, with the things below it moving up and down as
    appropriate. I'm not using absolute positioning or anthing fancy. I put the
    aforementioned section in a div:

    <div id="foo">
    ... optional stuff in here
    </div>

    when I want to hide it, I do this:

    document.getEle mentById("foo") .style.display= "none";

    and to show it again I do this:

    document.getEle mentById("foo") .style.display= "inline";

    This works fine in IE6 and Opera, but I have a problem with NN7. When the
    page comes up it's visible. the first time I hide it, it works fine, then I
    show it again and it works, the second time I try to hide it, nothing
    happens - the display style gets set to 'none' but the div is still visible
    on the page.

    if the div contains only text (no tags at all), it works OK every time.

    Can anybody throw any light on this or suggest possible workarounds?

    Many thanks

    Andy


  • Klaus Krtschil

    #2
    Re: problem with style.display=& quot;none&quot; in NN7

    Andy Fish schrieb:[color=blue]
    > Hi,
    >
    > I have a section of a web page that I want to be able to make appear and
    > disappear with javascript, with the things below it moving up and down as
    > appropriate. I'm not using absolute positioning or anthing fancy. I put the
    > aforementioned section in a div:
    >
    > <div id="foo">
    > ... optional stuff in here
    > </div>
    >
    > when I want to hide it, I do this:
    >
    > document.getEle mentById("foo") .style.display= "none";
    >
    > and to show it again I do this:
    >
    > document.getEle mentById("foo") .style.display= "inline";
    >
    > This works fine in IE6 and Opera, but I have a problem with NN7. When the
    > page comes up it's visible. the first time I hide it, it works fine, then I
    > show it again and it works, the second time I try to hide it, nothing
    > happens - the display style gets set to 'none' but the div is still visible
    > on the page.
    >
    > if the div contains only text (no tags at all), it works OK every time.
    >
    > Can anybody throw any light on this or suggest possible workarounds?
    >
    > Many thanks
    >
    > Andy
    >
    >[/color]

    Can you provide a link? That would help a lot.

    Klaus

    --
    Registered Linux user #54760

    Comment

    • Klaus Krtschil

      #3
      Re: problem with style.display=& quot;none&quot; in NN7

      Andy Fish schrieb:[color=blue]
      > Hi,
      >
      > I have a section of a web page that I want to be able to make appear and
      > disappear with javascript, with the things below it moving up and down as
      > appropriate. I'm not using absolute positioning or anthing fancy. I put the
      > aforementioned section in a div:
      >
      > <div id="foo">
      > ... optional stuff in here
      > </div>
      >
      > when I want to hide it, I do this:
      >
      > document.getEle mentById("foo") .style.display= "none";
      >
      > and to show it again I do this:
      >
      > document.getEle mentById("foo") .style.display= "inline";
      >
      > This works fine in IE6 and Opera, but I have a problem with NN7. When the
      > page comes up it's visible. the first time I hide it, it works fine, then I
      > show it again and it works, the second time I try to hide it, nothing
      > happens - the display style gets set to 'none' but the div is still visible
      > on the page.
      >
      > if the div contains only text (no tags at all), it works OK every time.
      >
      > Can anybody throw any light on this or suggest possible workarounds?
      >
      > Many thanks
      >
      > Andy
      >
      >[/color]

      Can you provide a link? That would help a lot.

      Klaus

      --
      Registered Linux user #54760

      Comment

      • Andy Fish

        #4
        Re: problem with style.display=& quot;none&quot; in NN7

        here's a complete stand-alone example:

        <HTML><head><sc ript language="javas cript">
        function Button1_onclick ()
        {document.getEl ementById("foo" ).style.display ="none";}
        function Button2_onclick ()
        {document.getEl ementById("foo" ).style.display ="inline";}
        </script></head>
        <BODY>
        <p>this is always visible</p>
        <div id="foo"><p>thi s is sometimes visible</p></div>
        <P>
        <INPUT id="Button1" type="button" value="Button" name="Button1"
        onclick="return Button1_onclick ()">
        <INPUT id="Button2" type="button" value="Button" name="Button2"
        onclick="return Button2_onclick ()">
        </P>
        </BODY>
        </HTML>

        click on the left button to make the text disappear and the right button to
        make it appear. on Netscape 7 it only works once then it stays visible all
        the time. other browsers seem to work OK.


        "Klaus Krtschil" <klauspk@gmx.de > wrote in message
        news:bh8033$tk3 6n$1@ID-105021.news.uni-berlin.de...
        [color=blue]
        >
        > Can you provide a link? That would help a lot.
        >
        > Klaus
        >
        > --
        > Registered Linux user #54760
        >[/color]


        Comment

        • Lee

          #5
          Re: problem with style.display=& quot;none&quot; in NN7

          Andy Fish said:[color=blue]
          >
          >here's a complete stand-alone example:
          >[...]
          >click on the left button to make the text disappear and the right button to
          >make it appear. on Netscape 7 it only works once then it stays visible all
          >the time. other browsers seem to work OK.[/color]

          It works fine for me in Netscape 7.1.
          What messages do you see in the JavaScript console?

          Comment

          • Robert E. Boughner

            #6
            Re: problem with style.display=& quot;none&quot; in NN7

            Makes sense since DIV is a block element whereas plain text is an inline
            element.

            Andy Fish wrote:[color=blue]
            > fixed it (I think)
            >
            > using the darwinian theory of natural selection, I tried making random
            > changes to the code to see if it would make any difference
            >
            > turns out that using style.display=" block" to make it visible (rather than
            > "inline" works OK).
            >
            > Andy
            >
            >
            > "Andy Fish" <ajfish@blueyon der.co.uk> wrote in message
            > news:y_LZa.3190 $8L5.25766950@n ews-text.cableinet. net...
            >[color=green]
            >>here's a complete stand-alone example:
            >>
            >><HTML><head>< script language="javas cript">
            >>function Button1_onclick ()
            >>{document.get ElementById("fo o").style.displ ay="none";}
            >>function Button2_onclick ()
            >>{document.get ElementById("fo o").style.displ ay="inline";}
            >></script></head>
            >> <BODY>
            >> <p>this is always visible</p>
            >> <div id="foo"><p>thi s is sometimes visible</p></div>
            >> <P>
            >> <INPUT id="Button1" type="button" value="Button" name="Button1"
            >>onclick="retu rn Button1_onclick ()">
            >> <INPUT id="Button2" type="button" value="Button" name="Button2"
            >>onclick="retu rn Button2_onclick ()">
            >> </P>
            >> </BODY>
            >></HTML>
            >>
            >>click on the left button to make the text disappear and the right button[/color]
            >
            > to
            >[color=green]
            >>make it appear. on Netscape 7 it only works once then it stays visible all
            >>the time. other browsers seem to work OK.
            >>
            >>
            >>"Klaus Krtschil" <klauspk@gmx.de > wrote in message
            >>news:bh8033$t k36n$1@ID-105021.news.uni-berlin.de...
            >>
            >>[color=darkred]
            >>>Can you provide a link? That would help a lot.
            >>>
            >>>Klaus
            >>>
            >>>--
            >>>Registered Linux user #54760
            >>>[/color]
            >>
            >>[/color]
            >
            >[/color]

            Comment

            • Andy Fish

              #7
              Re: problem with style.display=& quot;none&quot; in NN7

              I have netscape 7.01 - nothing was coming out on the JS console

              so maybe it was a bug and my fix was infact a workaround.

              "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
              news:bh87mq05ni @drn.newsguy.co m...[color=blue]
              > Andy Fish said:[color=green]
              > >
              > >here's a complete stand-alone example:
              > >[...]
              > >click on the left button to make the text disappear and the right button[/color][/color]
              to[color=blue][color=green]
              > >make it appear. on Netscape 7 it only works once then it stays visible[/color][/color]
              all[color=blue][color=green]
              > >the time. other browsers seem to work OK.[/color]
              >
              > It works fine for me in Netscape 7.1.
              > What messages do you see in the JavaScript console?
              >[/color]


              Comment

              • Klaus Krtschil

                #8
                Re: problem with style.display=& quot;none&quot; in NN7

                Andy Fish schrieb:[color=blue]
                > fixed it (I think)
                >
                > using the darwinian theory of natural selection, I tried making random
                > changes to the code to see if it would make any difference
                >
                > turns out that using style.display=" block" to make it visible (rather than
                > "inline" works OK).
                >
                > Andy
                >
                >
                > "Andy Fish" <ajfish@blueyon der.co.uk> wrote in message
                > news:y_LZa.3190 $8L5.25766950@n ews-text.cableinet. net...
                >[color=green]
                >>here's a complete stand-alone example:
                >>
                >><HTML><head>< script language="javas cript">
                >>function Button1_onclick ()
                >>{document.get ElementById("fo o").style.displ ay="none";}
                >>function Button2_onclick ()
                >>{document.get ElementById("fo o").style.displ ay="inline";}
                >></script></head>
                >> <BODY>
                >> <p>this is always visible</p>
                >> <div id="foo"><p>thi s is sometimes visible</p></div>
                >> <P>
                >> <INPUT id="Button1" type="button" value="Button" name="Button1"
                >>onclick="retu rn Button1_onclick ()">
                >> <INPUT id="Button2" type="button" value="Button" name="Button2"
                >>onclick="retu rn Button2_onclick ()">
                >> </P>
                >> </BODY>
                >></HTML>
                >>
                >>click on the left button to make the text disappear and the right button[/color]
                >
                > to
                >[color=green]
                >>make it appear. on Netscape 7 it only works once then it stays visible all
                >>the time. other browsers seem to work OK.
                >>
                >>
                >>"Klaus Krtschil" <klauspk@gmx.de > wrote in message
                >>news:bh8033$t k36n$1@ID-105021.news.uni-berlin.de...
                >>
                >>[color=darkred]
                >>>Can you provide a link? That would help a lot.
                >>>
                >>>Klaus
                >>>
                >>>--
                >>>Registered Linux user #54760
                >>>[/color]
                >>
                >>[/color]
                >
                >[/color]
                Both variants (block/inline) work with Moz 1.4 (Linux)

                Klaus

                --
                Registered Linux user #54760

                Comment

                • gavin long

                  #9
                  Re: problem with style.display=& quot;none&quot; in NN7

                  Andy Fish wrote:
                  [color=blue]
                  > turns out that using style.display=" block" to make it visible (rather than
                  > "inline" works OK).[/color]



                  [yikes! this thread is cross-posted all over the show. Follow-ups set
                  to n.p.m.browser]

                  --
                  gav


                  Comment

                  Working...