Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Detecting Language Of Visitor


tedster - 6:43 am on Jan 9, 2003 (gmt 0)


You may find this thread [webmasterworld.com] of interest. The consensus there seems to be that auto-detection of language is not a good idea in many cases. You can read the comments in the thread and judge for your self how they apply to your situation.

As to a script, I found this snippet tucked away (had to blow the dust off it!) It purports to do what you asked - that is, check for what "prefered language" was chosen in the browser setup. But I've never used it and can't vouch that it's dependable. In particular, it is an old script so I'm not sure that these are the current names for the object you need to check in more recent browsers.

<SCRIPT LANGUAGE="JavaScript1.2"><!--
if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.browserLanguage;
//--></SCRIPT>

[edited by: tedster at 7:22 am (utc) on Jan. 9, 2003]


Thread source:: http://www.webmasterworld.com/javascript/784.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com