Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
85
rated 0 times [  87] [ 2]  / answers: 1 / hits: 31651  / 15 Years ago, thu, march 19, 2009, 12:00:00

I am trying to get the lang value from the HTML tag, but the current JavaScript I am using doesn't work.



This is the HTML code I am trying to access:



<html  lang=it-IT>


And the Javascript



if(navigator.appName == 'Netscape')
{
langType = navigator.language;
}
else
{
langType = navigator.browserLanguage;
}


but in testing I still get the value EN-us



Can anyone help?



Thanks!


More From » javascript

 Answers
61

Use



document.documentElement.lang


As Rob has commented, your code gets the browser's language and not the document's.


[#99821] Friday, March 13, 2009, 16 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hailie

Total Points: 25
Total Questions: 112
Total Answers: 111

Location: Belize
Member since Tue, Dec 8, 2020
3 Years ago
hailie questions
;