[Javascript] [Beginner] What is going on with my show/hide function?

Matt Warden mwarden at gmail.com
Mon Nov 13 13:27:02 CST 2006


On 11/13/06, Paul Novitski <paul at juniperwebcraft.com> wrote:
> With an eye to minimalist programming, I'd like to suggest that it's
> not necessary to use javascript to create or manipulate classes at
> all.  Just set up a static stylesheet:
>
>          .showInline { display: inline; }
>          .showBlock  { display: block; }
>          .hidden     { display: none; }
>
> ...then change the element's className with javascript.  That way the
> methods of hiding & showing remain discretely in the presentational
> layer, separate from the mechanics of toggling, allowing these two
> aspects of your application to be modified more independently of one another.

Paul, this is exactly what Roger and I suggested. Take another look at
the YUI link I provided.


> To reiterate an earlier point, toggling display apparently breaks in
> some screen readers that don't report elements making the transition
> from none to block or inline.

This is a common misconception. This only happens in "virtual buffer
mode" (every screen reader has a different name for this mode) and
only when the transition is triggered by a "non-standard" action. If
it happens upon link click, for example, there is no issue. If it
happens upon some timeout and the reader is in virtual buffer mode,
then it will notice no change (this is true whether the change is to
display or anything else).


> Does your page remain usable if the div doesn't hide?  If so, you can
> toggle its visibility for sighted users by changing its position
> while leaving it readable by non-visual user agents:
>
>          .shown
>          {
>                  position: static;
>          }
>          .hidden
>          {
>                  position: absolute;
>                  left: -1000px;
>          }

I see this a lot and I cant really think of an instance where I would
want both to be visible to screen readers at the same time, but only
one visible to sighted users. The only time I would use this is to
provide additional instructions to screen reader users, or something.


-- 
Matt Warden
Cleveland, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the Javascript mailing list