Closed Bug 87837 Opened 24 years ago Closed 23 years ago

Problems with style.display="none"

Categories

(Core :: DOM: CSS Object Model, defect)

x86
Windows 98
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 97874

People

(Reporter: amla70, Assigned: jst)

Details

Attachments

(1 file)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.1+) Gecko/20010625 BuildID: 2001062504 Changing display of a span with a div inside of it fails to hide the span after it has been made visible. Reproducible: Always Steps to Reproduce: I'll attach this code, but this is a function to toggle visibility of any element of the page: <script language="JavaScript" type="text/javascript"> <!-- function ShowHide(name) { capa=document.getElementById(name); window.status = "Previous: " + capa.style.display; if (capa.style.display=="") capa.style.display="none"; //hide else { capa.style.display=""; //show } } //--> </script> and then, it is called in this link, but after hiding the test zone once it won't hide it anymore: <a href="javascript:ShowHide('test3');">zone is a span with a div inside. This one fails</a><br> <span id="test3"><div>test zone</div></span> Actual Results: After the span with a div inside has been made hidden once (by javascript or by initial style) it can't be hidden again. Expected Results: Been able to always toggle visibility of any element. This is a regression. In the 0.9.1 it works correctly. I've dowloaded the older nightly that I found (061008) and it also happens there. Dont know if this is related to bug #87485
This markup is invalid; the span element is inline and the div element is block. You should use div elements to enclose span elements, not the other way around. Probably should be marked WONTFIX.
Christopher, I disagree that this should be marked wontfix. Regardless of whether the markup is legal, the DOM manipulation should be consistent. It doesn't make sense that DOM-style manipulation should be ignored after the first time. Especially since it worked in 0.9.1. Confirming this incorrect behavior on Win98 and Win2K build 2001062504.
Thank you for both comments. Christopher: I'll change my markup to remove the div, but I agree with Jason that this is inconsistent. If this is due to bad markup then this shouldn't work at all, not only the first time which has misleaded me.
markign NEW.
Status: UNCONFIRMED → NEW
Ever confirmed: true
I have experienced the following problem which is probably related: Using: <span onclick="document.getElementById('test').style.display=''">Show</span> <span onclick="document.getElementById('test').style.display='none'">Hide</span> <table id=test><tr><td>Example: showing and hiding entire table</td></tr></table> The table will be hidden with the first click on hide, but if you click show and then hide again, the table will not be hidden. I have displayed the status of the display property in the status bar and it does change with each click of show/hide so it appears to be a rendering problem.
After some further experimentation I have discovered that the following script produces several rendering errors. (tested on the latest release of Netscape 6.1, works perfectly under IE5.5) The style.display property appears to work, but the rendering is wrong; when showing after a hide, some of the rows are drawn below others, so row 1 is incorrectly drawn and row5 appears 2nd as well as 5th! Try my code below and see. <html> <head> <title>Select hosts:</title> <script language=Javascript> var nodes = new Array() function hide() { document.getElementById('row1').style.display='none'; document.getElementById('row3').style.display='none'; document.getElementById('row4').style.display='none'; } function show() { document.getElementById('row1').style.display=''; document.getElementById('row3').style.display=''; document.getElementById('row4').style.display=''; } </script> </head> <body> <p> <span onclick="show()">Show all rows</span><br> <span onclick="hide()">Hide rows 1,3,4</span> </p> <table> <tr id=row1><td><font color=grey>row1</font></td></tr> <tr id=row2><td><font >row2</font></td></tr> <tr id=row3><td><font color=grey>row3</font></td></tr> <tr id=row4><td><font color=grey>row4</font></td></tr> <tr id=row5><td><font >row5</font></td></tr> </table> </body> </html>
Bug 97874 has a clearer problem description *** This bug has been marked as a duplicate of 97874 ***
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: