Closed Bug 183318 Opened 21 years ago Closed 21 years ago

behaviour for hiding/displaying parts of a page works _inconsistently_

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows NT
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 173373

People

(Reporter: athleston, Assigned: jst)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
Build Identifier: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0

This javascript function toggles the display of a named page element:

function Outline(sID){
    var  oElem = document.getElementById(sID);
    if (oElem){
      oElem.style.display = (oElem.style.display == "none") ? "" : "none";
    }
}

It _will_ hide/display any named element if the browser is IE4+. 
In Mozilla 1.0/Netscape 7.0, it will _display_ the hidden element but _wont_ hide


Reproducible: Always

Steps to Reproduce:
1. create a named HTML element eg. <p ID='Foo' style='display:none;'>See me?</p>
2. create a javascript block with the above-listed 'Outline' function
3. write a nearby onclick event eg: <p onclick="Outline('Foo');">Click Here</p>
3. view in Netscape 7.0/Mozilla 1.0: mouse-click on 'Click Here'

Actual Results:  
The hidden paragraph will not be visible when the page loads. Clicking on the
'Click Here' will reveal the hidden paragraph but clicking again _does_not_ hide
the element, as it should.

Expected Results:  
If Mozilla is kind enough to reveal the hidden element, it should be able to
hide the element again!

This is really an issue about how Mozilla dynamically re-draws the DOM
This is a sample HTML page...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html>
<head>
  <title>Test Page</title>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
  <script type="text/javascript" language="javascript">
  <!--begin Hiding

  //Purpose: Expands/Collapses a given element
    function Outline(sID) {
      var  oElem = document.getElementById(sID);
      if (oElem){
        oElem.style.display = (oElem.style.display == "none") ? "" : "none";
      }
    }

  //end Hiding -->
  </script>
</head>
<body>

<h1>Bug 183318 Submitted</h1>

See hidden text...

<span ID="Foo" style="display:none;">

<table border="0px" cellspacing="0px"  cellpadding="3px">
  <tr>
    <td>

  <em>The Style object lets you implement dynamic HTML style sheets in
JavaScript. The methods and properties of the Style object implement the
cascading style sheet style properties of HTML in JavaScript.</em>

    </td>
    </tr>
</table>

</span>?

<p onclick="javascript:Outline('Foo')">Click here!</p>

</body>
</html>

Looks like bug 173373 (and also works in my debug tree though not in nightlies).
Depends on: 173373

*** This bug has been marked as a duplicate of 173373 ***
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.