Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use navigator.language/browserLanguage 1

Status
Not open for further replies.

j4606

MIS
Nov 28, 2005
349
US
I've been searching for a way to redirect users to a website with their preferred browsing language.

The code seems simple enough.
Code:
 var userLang = (navigator.language) ? navigator.language : navigator.browserLanguage;

The above works but when I go into my language options in both ie and firefox, and change my language preference, userLang still alerts to en-US. I want to stay away from ie only properties such as systemLanguage.

I can't really find to much documentation on the subject anyone have any info on this or an example I can view?

I thought changing my preferred language would change my userLang var. I notice that if I change my preferred lang google redirects me to a site with that lang I want to emulate that behavior with out having to use http header values.
 
Hi

Such detections and redirects should be done on server side. The [tt]navigator.language[/tt] is the browser's interface language, not the user's preference. The settings for the preferred document language is not accessible from JavaScript.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top