Im trying to make a laguage detection, this code detect the language from the web browser, and it works almost ok, but in MAC dosent work I test the page in OS X and OS 9, some one can give me a hand?
Thank you for STOP in my question nad for any help!
* One more thing someone can tell me how some web sites can detect your country? And how can I detect the language from the OS ?
——————————–CODE——————————
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title></title>
<META HTTP-EQUIV=”Pragma” CONTENT=”no-cache”>
<META HTTP-EQUIV=”Expires” CONTENT=”-1″>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<script>
//Enter ISO 639-2 letter Language codes to detect (see: [url]http://www.w3.org/WAI/ER/IG/ert/iso639.htm
var langcodes=new Array(“en”, “fr”, “es”, “pt”, “de”, “it”, “default”)
//Enter corresponding redirect URLs (last one is for default URL):
var langredirects=new Array(“en.php”, “fr.php”, “es.php”, “pt.php”, “de.php”, “it.php”, “en.php”)
var languageinfo=navigator.language? navigator.language : navigator.userLanguage
var gotodefault=1
function redirectpage(dest){
if (window.location.replace)
window.location.replace(dest)
else
window.location=dest
}
for (i=0;i<langcodes.length-1;i++){
if (languageinfo.substr(0,2)==langcodes[i]){
redirectpage(langredirects[i])
gotodefault=0
break
}
}
if (gotodefault)
redirectpage(langredirects[langcodes.length-1])
</script>
</head>
<body>
<br>
<br>
<br>
</body>
</html>