On Dec 16, 7:05 am, "Claus Reinke" <[email protected]> wrote:
> There is a widespread pattern on the web that I don't understand.
>
> I start with the problem statement, then suggest a workaround
> that I would like to get feedback on. I close with the suggestion
> that the interplay of CSS and noscript could be improved by a
> :noscript CSS-pseudoselector.
NAK. Hasty conclusion.
> Take Google+ as an example, though there are many Javascript-
> using sites with similar issues. Pages start with something like
>
> <style>
> body { visibility: hidden; }
> </style>
>
> and then Javascript is used to override that default. For instance
>
> https://plus.google.com/111191895515210271225/posts/HN2ZTbf7Cgg
>
> I assume there is some rationale for hiding content by default?
> Perhaps it is that if one shows content by default, there would
> be a flash of uncontrolled content before the scripts run.
>
> The problem is that users who disable Javascript by default see
> nothing at all on such sites, even though the content could be
> read just fine by removing the default styling. Try the example.
>
ACK.
> If the rationale above is correct, there would seem to be a simple
> workaround, which is to hide content via a css class, and to attach
> that class dynamically, before the content is parsed and rendered.
> That way content is hidden by default only when script is enabled:
>
You could do that, sure.
> ..
> <style>
> .script .hidden {display:none}
> </style>
> </head>
>
> <body>
>
> <script>
> document.body.className = "script";
> </script>
>
> <!-- no script: text visible -->
> <!-- with script: text not visible by default,
> can be made visible by script, when ready
> -->
> <div class="hidden">
> hear this
> </div>
> ..
>
> Am I missing something here? If this works as expected, then
> why do major players like Google+ (don't get me started on
> Twitter) fail to make their content accessible to non-Javascript
> users?
>
Willful ignorance? The problems with such approaches have been
discussed for over 10 years.
> While looking into this, it occurred to me that the noscript
> element isn't half as useful as it could be - in particular, we
> might be better of with script/noscript CSS-pseudoselectors:
>
> <style>
> :script { display: none }
> </style>
>
> I would like your feedback on these observations: am I on
> the right track?
>
A browser supporting JavaScript itself is usually not enough. A few
things like `window` or `document` can be safely assumed. Beyond that
requires feature testing.
if(document.body) {
document.body.className = "foo-support";
}
--
Garrett
Twitter: @xkit
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]