Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #35813

Re: Lang attribute on html element

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Lang attribute on html element
Date 2018-11-13 22:40 +0100
Organization PointedEars Software (PES)
Message-ID <bcb87f6a-e872-2a5f-548d-d9bfa6522118@PointedEars.de> (permalink)
References <C5mdnbpmv72Q13fGnZ2dnUU7-KfNnZ2d@westnet.com.au> <4LGdnXHeh6YRwXfGnZ2dnUU7-N-dnZ2d@westnet.com.au>

Show all headers | View raw


Andrew Poulos wrote:
> On 13/11/2018 2:50 pm, Andrew Poulos wrote:
>> I have a page that onload runs some JavaScript that sets a value for 
>> lang on the html element.
>>
>> What concerns me is that if this is "too late" for screen readers to 
>> correctly interpret the page's language. That is, does the appropriate 
>> lang attribute need to be hard coded in the page for screen readers to 
>> recognise it?
>>
>> Would using DOMContentLoaded be safer?
> 
> After some testing, using DOMContentLoaded triggers Chrome to ask if I 
> want the page translated so maybe it will also be picked up by screen 
> readers.

Your argument is based on the assumption that all user agents with which
screen readers can be used also execute client-side scripting (in a
DOM-compatible way).  This assumption is false: a prominent counter-example
is Lynx.

Therefore, too, always generate the initial “lang” attribute value
*server-side*.


PointedEars
-- 
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Lang attribute on html element Andrew Poulos <ap_prog@hotmail.com> - 2018-11-13 14:50 +1100
  Re: Lang attribute on html element Andrew Poulos <ap_prog@hotmail.com> - 2018-11-13 16:09 +1100
    Re: Lang attribute on html element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-11-13 22:40 +0100
      Re: Lang attribute on html element Andrew Poulos <ap_prog@hotmail.com> - 2018-11-14 10:00 +1100

csiph-web