Get the user languageTag(s): Language


For Netscape, use navigator.language
For IEv4, it's navigator.browserLanguage or navigator.userLanguage
if (navigator.appName == 'Netscape')
    var language = navigator.language;
else
    var language = navigator.browserLanguage;

var code = language.substring(0,2);

document.write("<P>Language = " + code);
Right now, here what this script is saying about your browser :

An alternative technique is :

var start = navigator.userAgent.indexOf('[');
if (start > -1) {
    var end = navigator.userAgent.indexOf(']');
    if (end > -1) {
        var language = navigator.userAgent.substring(start+1,end);
        document.write("<P>Language = " + language);
    }
       
} else document.write( "Language  no info available ");
document.write( "<br>user-agent :  " + navigator.userAgent);

Here what this script is saying about your browser :


blog comments powered by Disqus