HighDots Forums  

Re: newbie: question on accessing lang attributes

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: newbie: question on accessing lang attributes in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
RobG
 
Posts: n/a

Default Re: newbie: question on accessing lang attributes - 01-07-2005 , 01:57 AM






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


Reply With Quote
  #2  
Old   
ConCat
 
Posts: n/a

Default Re: newbie: question on accessing lang attributes - 01-08-2005 , 01:11 AM






Rob, thanks for the JS help - much appreciated.
I visited the links re the language stuff, but it seems extremely
convoluted.
Too bad they can't explain things in a simple fashion!
I'll have to stick to my two known meta-tags until I get some kind of
easy-to-understand rule about the new Dublin initiative.

Gary



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.