HighDots Forums  

display:normal?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss display:normal? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Spartanicus
 
Posts: n/a

Default Re: display:normal? - 02-03-2006 , 04:24 PM






Markus Ernst <derernst@NO#SP#AMgmx.ch> wrote:

Quote:
When toggling an element on and off by setting its display property via
DOM access, display:none is valid for all kinds of elements, but I can't
find anything about a generic value for toggling on again.

There is no such value, nor is one needed.

I assume I understand why there is none needed - by knowing the element
type the default display value is known, too (under ideal circumstances,
though).
Under all circumstances.

If you can produce a use case where the element cannot reasonably be
determined then you may have an argument for a 'normal' value feature
request for the display property.

--
Spartanicus


Reply With Quote
  #12  
Old   
Michael Winter
 
Posts: n/a

Default Re: display:normal? - 02-05-2006 , 07:22 PM






On 03/02/2006 10:37, Markus Ernst wrote:

[snip]

Quote:
object.style.display = 'none'; // off
object.style.display = ''; // default or class-definition

'' did not work in FF (so I did not even try it in IE...).
It does but, as Niels briefly noted, the computed value that results
from such an assignment depends on the default and author style sheets.
If a document-wide style sheet hides the element (which is arguably a
bad idea, anyway), assigning an empty string will not reveal it.

That is,

#example {
display: none;
}

<div id="example">...</div>

element.style.display = '';

(where element is a reference to the DIV element) will not work, whereas

<div id="example" style="display: none;">...</div>

or

<div id="example">...</div>

element.style.display = 'none';

followed by

element.style.display = '';

will.

The last example, where the element is hidden using only the DOM, is
much preferred (with added feature detection) as it doesn't have the
potential for rendering a document unusable where scripting support is
insufficient or unavailable.

[snip]

If you are still having problems, post to c.l.javascript.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.


Reply With Quote
  #13  
Old   
Markus Ernst
 
Posts: n/a

Default Re: display:normal? - 02-06-2006 , 02:59 AM



Spartanicus schrieb:
Quote:
I assume I understand why there is none needed - by knowing the element
type the default display value is known, too (under ideal circumstances,
though).


Under all circumstances.

If you can produce a use case where the element cannot reasonably be
determined then you may have an argument for a 'normal' value feature
request for the display property.

With ideal circumstances I meant, all browsers behaving as expected.
Anyway I see the points clear now, and of course IE misbehaviour is no
argument for a spec change request. Thank you for your comments!

Markus


Reply With Quote
  #14  
Old   
Markus Ernst
 
Posts: n/a

Default Re: display:normal? - 02-06-2006 , 03:02 AM



niels.froehling (AT) seies (DOT) de schrieb:
Quote:
Then you make something /wrong/.
It works perfectly as seen in
http://www.paradice-insight.us/tests/display.html
Thank you, your example and Michael's comment make it perfectly clear to
me :-)

Markus


Reply With Quote
  #15  
Old   
Markus Ernst
 
Posts: n/a

Default Re: display:normal? - 02-06-2006 , 03:04 AM



Michael Winter schrieb:
Quote:
The last example, where the element is hidden using only the DOM, is
much preferred (with added feature detection) as it doesn't have the
potential for rendering a document unusable where scripting support is
insufficient or unavailable.
Thank you, this is an important point I usually think of, but did not
see in this case!

Markus


Reply With Quote
  #16  
Old   
Markus Ernst
 
Posts: n/a

Default Re: display:normal? - 02-06-2006 , 03:07 AM



Harlan Messinger schrieb:
Quote:
When toggling an element on and off by setting its display property
via DOM access, display:none is valid for all kinds of elements, but I
can't find anything about a generic value for toggling on again.


The time-honored approach for restoring the previous value when you
don't know what it is at programming time: save it first, before setting
the new value.

var oldDisplay = el.style.display;
el.style.display = "none";

// later ...

el.style.display = oldDisplay;
That's great! Thanks!
Markus


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.