ConCat wrote:
Quote:
Hello,
[...]
mind (always looking for short-cuts, aren't we? thought: If I could
"capture" the language attrib for the page in a string variable (ie, "fr"
for french), I could insert a much more universal JS nav snippet which would
automatically adjust for the language on the page by parsing the html head
for the language attribute.
is this a possibility, or am I dreaming too vividly? |
To get the lang attribute of the HTML tag:
var eAtt = document.getElementsByTagName('html')[0].attributes;
var eLang = eAtt.lang.value;
However, I think when specifying the language of the actual page,
you should use a meta tag compliant with a meta data standard
(say Dublin Core) and the language should come from RFC 1766:
<URL:http://dublincore.org/documents/1998/09/dces/#>
<URL:http://www.ietf.org/rfc/rfc1766.txt>
<META NAME="Language" CONTENT="fr">
You can get the appropriate meta tag value similarly to the HTML
example and get its content property:
var langTag = document.getElementsByTagName('meta')['Language'];
var langAtt = langTag.content;
alert(langAtt);
Of course you should also feature test getElementsByTagName
before using it and offer a document.all method to suit users of
older IE browsers.
--
Rob