Browser language detection, suitable for multilingual version of the site

Source: Internet
Author: User
browsers | Site If your site is for surfers around the world or for business, it's very realistic to test the browser language type of visitors. provided here
The script can detect the reveal, the browser language type, the general Chinese can be recognized as "en", the English version can be recognized as "en", and then according to the judgment of the bangs
A browser language type guides a page in a different language version. Of course, you can use the server to solve this problem, the client with this script on it.

You need to place the code in the <script language= "JavaScript1.2" >
<!--//
if (navigator.appname = ' Netscape ')
var language = Navigator.language;
Else
var language = Navigator.browserlanguage;


if (language.indexof (' en ') >-1) document.location.href = ' english.htm ';
else if (Language.indexof (' nl ') >-1) document.location.href = ' dutch.htm ';
else if (Language.indexof (' fr ') >-1) document.location.href = ' french.htm ';
else if (language.indexof (' de ') >-1) document.location.href = ' german.htm ';
else if (language.indexof (' ja ') >-1) document.location.href = ' japanese.htm ';
else if (language.indexof (' it ') >-1) document.location.href = ' italian.htm ';
else if (Language.indexof (' pt ') >-1) document.location.href = ' portuguese.htm ';
else if (language.indexof (' es ') >-1) document.location.href = ' spanish.htm ';
else if (language.indexof (' SV ') >-1) document.location.href = ' swedish.htm ';
else if (language.indexof (' en ') >-1) document.location.href = ' chinese.htm ';
Else
Document.location.href = ' english.htm ';
End-->
</script>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.