Wednesday 20 March 2013

Check the Default Browser Language Using Javascript [Compatible with IE]


Check the Default Browser Language Using JavaScript [Compatible with IE]


Check The Default Language of Client Browser using the following JavaScript... 

Note: This works in IE only.



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>User Language</title>
    
    <SCRIPT LANGUAGE="JavaScript">

//Works in Internet Explorer

<!-- Begin
if (navigator.browserLanguage.substr(0,2) == "af")
  document.write('Afrikaans')
else if (navigator.browserLanguage.substr(0,2) == "ar")
{
 if (navigator.browserLanguage.substr(3,2) == "ae")
  document.write('Arabic / United Arab Emirates')
 else if (navigator.browserLanguage.substr(3,2) == "bh")
  document.write('Arabic / Bahrain')
 else if (navigator.browserLanguage.substr(3,2) == "eg")
  document.write('Arabic / Egypt')
 else if (navigator.browserLanguage.substr(3,2) == "dz")
  document.write('Arabic / Algeria')
 else if (navigator.browserLanguage.substr(3,2) == "iq")
  document.write('Arabic / Iraq')
 else if (navigator.browserLanguage.substr(3,2) == "jo")
  document.write('Arabic / Jordan')
 else if (navigator.browserLanguage.substr(3,2) == "kw")
  document.write('Arabic / Kuwait')
 else if (navigator.browserLanguage.substr(3,2) == "lb")
  document.write('Arabic / Lebanon')
 else if (navigator.browserLanguage.substr(3,2) == "ly")
  document.write('Arabic / Libya')
 else if (navigator.browserLanguage.substr(3,2) == "ma")
  document.write('Arabic / Morocco')
 else if (navigator.browserLanguage.substr(3,2) == "om")
  document.write('Arabic / Oman')
 else if (navigator.browserLanguage.substr(3,2) == "qa")
  document.write('Arabic / Qatar')
 else if (navigator.browserLanguage.substr(3,2) == "sa")
  document.write('Arabic / Saudi Arabia')
 else if (navigator.browserLanguage.substr(3,2) == "sy")
  document.write('Arabic / Syria')
 else if (navigator.browserLanguage.substr(3,2) == "tn")
  document.write('Arabic / Tunisia')
 else if (navigator.browserLanguage.substr(3,2) == "ye")
  document.write('Arabic / Yemen')
 else document.write('Arabic')
}
else if (navigator.browserLanguage.substr(0,2) == "be")
  document.write('Belarusian')
else if (navigator.browserLanguage.substr(0,2) == "bg")
  document.write('Bulgarian')
else if (navigator.browserLanguage.substr(0,2) == "ca")
  document.write('Catalan')
else if (navigator.browserLanguage.substr(0,2) == "cs")
  document.write('Czech')
else if (navigator.browserLanguage.substr(0,2) == "da")
  document.write('Danish')
else if (navigator.browserLanguage.substr(0,2) == "de")
{
 if (navigator.browserLanguage.substr(3,2) == "at")
  document.write('German / Austria')
 else if (navigator.browserLanguage.substr(3,2) == "ch")
  document.write('German / Switzerland')
 else if (navigator.browserLanguage.substr(3,2) == "li")
  document.write('German / Liechtenstein')
 else if (navigator.browserLanguage.substr(3,2) == "lu")
  document.write('German / Luxembourg')
else document.write('German / Germany')
}
else if (navigator.browserLanguage.substr(0,2) == "el")
  document.write('Greek / Greece')
else if (navigator.browserLanguage.substr(0,2) == "en")
{
 if (navigator.browserLanguage.substr(3,2) == "us")
  document.write('English / United States')
 else if (navigator.browserLanguage.substr(3,2) == "au")
  document.write('English / Austrailia')
 else if (navigator.browserLanguage.substr(3,2) == "bz")
  document.write('English / Belize')
 else if (navigator.browserLanguage.substr(3,2) == "ca")
  document.write('English / Canada')
 else if (navigator.browserLanguage.substr(3,2) == "gb")
  document.write('English / Great Britain')
 else if (navigator.browserLanguage.substr(3,2) == "ie")
  document.write('English / Ireland')
 else if (navigator.browserLanguage.substr(3,2) == "jm")
  document.write('English / Jamaica')
 else if (navigator.browserLanguage.substr(3,2) == "nz")
  document.write('English / New Zealand')
 else if (navigator.browserLanguage.substr(3,2) == "tt")
  document.write('English / Trinidad')
 else if (navigator.browserLanguage.substr(3,2) == "za")
  document.write('English / South Africa')
 else document.write('English')
}
else if (navigator.browserLanguage.substr(0,2) == "es")
{
 if (navigator.browserLanguage.substr(3,2) == "ar")
  document.write('Spanish / Argentina')
 else if (navigator.browserLanguage.substr(3,2) == "bo")
  document.write('Spanish / Bolivia')
 else if (navigator.browserLanguage.substr(3,2) == "cl")
  document.write('Spanish / Chile')
 else if (navigator.browserLanguage.substr(3,2) == "co")
  document.write('Spanish / Colombia')
 else if (navigator.browserLanguage.substr(3,2) == "cr")
  document.write('Spanish / Costa Rica')
 else if (navigator.browserLanguage.substr(3,2) == "do")
  document.write('Spanish / Dominican Republic')
 else if (navigator.browserLanguage.substr(3,2) == "ec")
  document.write('Spanish / Ecuador')
 else if (navigator.browserLanguage.substr(3,2) == "gt")
  document.write('Spanish / Guatemala')
 else if (navigator.browserLanguage.substr(3,2) == "hn")
  document.write('Spanish / Honduras')
 else if (navigator.browserLanguage.substr(3,2) == "mx")
  document.write('Spanish / Mexico')
 else if (navigator.browserLanguage.substr(3,2) == "ni")
  document.write('Spanish / Nicaragua')
 else if (navigator.browserLanguage.substr(3,2) == "pa")
  document.write('Spanish / Panama')
 else if (navigator.browserLanguage.substr(3,2) == "pe")
  document.write('Spanish / Peru')
 else if (navigator.browserLanguage.substr(3,2) == "pr")
  document.write('Spanish / Puerto Rico')
 else if (navigator.browserLanguage.substr(3,2) == "py")
  document.write('Spanish / Paraguay')
 else if (navigator.browserLanguage.substr(3,2) == "sv")
  document.write('Spanish / El Salvador')
 else if (navigator.browserLanguage.substr(3,2) == "uy")
  document.write('Spanish / Uruguay')
 else if (navigator.browserLanguage.substr(3,2) == "ve")
  document.write('Spanish / Venezuela')
 else document.write('Spanish / Spain')
}
else if (navigator.browserLanguage.substr(0,2) == "et")
  document.write('Estonian')
else if (navigator.browserLanguage.substr(0,2) == "eu")
  document.write('Basque')
else if (navigator.browserLanguage.substr(0,2) == "fa")
  document.write('Farsi')
else if (navigator.browserLanguage.substr(0,2) == "fi")
  document.write('Finnish')
else if (navigator.browserLanguage.substr(0,2) == "fo")
  document.write('Faeroese')
else if (navigator.browserLanguage.substr(0,2) == "fr")
{
 if (navigator.browserLanguage.substr(3,2) == "be")
  document.write('French / Belgium')
 else if (navigator.browserLanguage.substr(3,2) == "ca")
  document.write('French / Canada')
 else if (navigator.browserLanguage.substr(3,2) == "ch")
  document.write('French / Switzerland')
 else if (navigator.browserLanguage.substr(3,2) == "ca")
  document.write('French / Luxembourg')
 else document.write('French / France')
}
else if (navigator.browserLanguage.substr(0,2) == "gd")
{
 if (navigator.browserLanguage.substr(3,2) == "ie")
  document.write('Gaelic / Ireland')
 else document.write('Gaelic / Scotland')
}
else if (navigator.browserLanguage.substr(0,2) == "he")
  document.write('Hebrew')
else if (navigator.browserLanguage.substr(0,2) == "hi")
  document.write('Hindi')
else if (navigator.browserLanguage.substr(0,2) == "hr")
  document.write('Croatian')
else if (navigator.browserLanguage.substr(0,2) == "hu")
  document.write('Hungarian')
else if (navigator.browserLanguage.substr(0,2) == "in")
  document.write('Indonesian')
else if (navigator.browserLanguage.substr(0,2) == "is")
  document.write('Icelandic')
else if (navigator.browserLanguage.substr(0,2) == "he")
  document.write('Hebrew')
else if (navigator.browserLanguage.substr(0,2) == "it")
{
 if (navigator.browserLanguage.substr(3,2) == "ch")
  document.write('Italian / Switzerland')
 else document.write('Italian / Italy')
}
else if (navigator.browserLanguage.substr(0,2) == "ja")
  document.write('Japanese / Japan')
else if (navigator.browserLanguage.substr(0,2) == "ji")
  document.write('Yiddish')
else if (navigator.browserLanguage.substr(0,2) == "ko")
  document.write('Korean / Korea')
else if (navigator.browserLanguage.substr(0,2) == "lt")
  document.write('Lithuanian / Lithuania')
else if (navigator.browserLanguage.substr(0,2) == "lv")
  document.write('Latvian')
else if (navigator.browserLanguage.substr(0,2) == "mk")
  document.write('Macedonian / Macedonia')
else if (navigator.browserLanguage.substr(0,2) == "ms")
  document.write('Malaysian / Malaysia')
else if (navigator.browserLanguage.substr(0,2) == "mt")
  document.write('Maltese / Malta')
else if (navigator.browserLanguage.substr(0,2) == "nl")
{
 if (navigator.browserLanguage.substr(3,2) == "be")
  document.write('Dutch / Belgium')
 else document.write('Dutch / Netherlands')
}
else if (navigator.browserLanguage.substr(0,2) == "pl")
  document.write('Polish / Poland')
else if (navigator.browserLanguage.substr(0,2) == "pt")
{
 if (navigator.browserLanguage.substr(3,2) == "br")
  document.write('Portuguese / Brazil')
 else document.write('Portuguese / Portugual')
}
else if (navigator.browserLanguage.substr(0,2) == "rm")
  document.write('Rhaeto-Romanic / Romania')
else if (navigator.browserLanguage.substr(0,2) == "ro")
  document.write('Romanian / Romania')
else if (navigator.browserLanguage.substr(0,2) == "ru")
  document.write('Russian / Russia')
else if (navigator.browserLanguage.substr(0,2) == "sb")
  document.write('Sorbian')
else if (navigator.browserLanguage.substr(0,2) == "sk")
  document.write('Slovak')
else if (navigator.browserLanguage.substr(0,2) == "sl")
  document.write('Slovenian')
else if (navigator.browserLanguage.substr(0,2) == "sq")
  document.write('Albanian / Albania')
else if (navigator.browserLanguage.substr(0,2) == "sr")
  document.write('Serbian / Serbia')
else if (navigator.browserLanguage.substr(0,2) == "sv")
{
 if (navigator.browserLanguage.substr(3,2) == "fi")
  document.write('Swedish / Finland')
 else document.write('Swedish / Sweden')
}
else if (navigator.browserLanguage.substr(0,2) == "sx")
  document.write('Sutu')
else if (navigator.browserLanguage.substr(0,2) == "sz")
  document.write('Sami')
else if (navigator.browserLanguage.substr(0,2) == "th")
  document.write('Thai / Thailand')
else if (navigator.browserLanguage.substr(0,2) == "tn")
  document.write('Tswana')
else if (navigator.browserLanguage.substr(0,2) == "tr")
  document.write('Turkish / Turkey')
else if (navigator.browserLanguage.substr(0,2) == "ts")
  document.write('Tsonga')
else if (navigator.browserLanguage.substr(0,2) == "uk")
  document.write('Ukrainian')
else if (navigator.browserLanguage.substr(0,2) == "th")
  document.write('Thai / Thailand')
else if (navigator.browserLanguage.substr(0,2) == "ur")
  document.write('Urdu')
else if (navigator.browserLanguage.substr(0,2) == "ve")
  document.write('Venda')
else if (navigator.browserLanguage.substr(0,2) == "vi")
  document.write('Vietnamese / Vietnam')
else if (navigator.browserLanguage.substr(0,2) == "xh")
  document.write('Xhosa')
else if (navigator.browserLanguage.substr(0,2) == "zh")
{
 if (navigator.browserLanguage.substr(3,2) == "cn")
  document.write('Chinese / China')
 else if (navigator.browserLanguage.substr(3,2) == "hk")
  document.write('Chinese / Hong Kong')
 else if (navigator.browserLanguage.substr(3,2) == "sg")
  document.write('Chinese / Singapore')
 else if (navigator.browserLanguage.substr(3,2) == "tw")
  document.write('Chinese / Taiwan')
 else document.write('Chinese / China')
}
else if (navigator.browserLanguage.substr(0,2) == "zu")
  document.write('Zulu')
else
  document.write('Could not be determined')
//  End -->
</script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top