NN 4, IE 4
You wish to direct users automatically to a path in your web site tailored for a specific written language.
Version 4 and later browsers provide properties of the
navigator
object that let you read the code for
the native language for which the user’s browser was
developed. Unfortunately, the property names are different for each
browser, so you must perform some object property detection in the
process. The solution below assumes that all users will be shunted to
the English page unless their browsers indicate that the native
language is German:
// verify browser language function getLang(type) { var lang; if (typeof navigator.userLanguage != "undefined") { lang = navigator.userLanguage.toUpperCase( ); } else if (typeof navigator.language != "undefined") { lang = navigator.language.toUpperCase( ); } return (lang && lang.indexOf(type.toUpperCase( )) = = 0) } ... location.href = (getLang("de")) ? "de/home.html" : "en/home.html";