Automatic jump Chinese and English page code

Source: Internet
Author: User
Page | Auto Jump

PHP Web page According to the visitor's browser language different automatically jump Chinese and English pages
When the visitor's browser language is Chinese, enter the Chinese page
Foreign user default browser is not Chinese to jump English page

PHP Code:

?
$lan = substr ($HTTP _accept_language,0,5);
if ($lan = = "ZH-CN")
Print ("<meta http-equiv= ' refresh ' content = ' 0; URL = Gb/index.htm ' > ');
Else
Print ("<meta http-equiv= ' refresh ' content = ' 0; URL = En/index.htm ' > ');
?>


HTML Web page According to the browser language of visiting this different automatic jump multilingual page
Add the following code between:

<script>
var type=navigator.appname
if (type== "Netscape")
var lang = Navigator.language
Else
var lang = Navigator.userlanguage

Cut down to 2 chars of country code
var lang = lang.substr (0,2)

English
if (lang = = "en")
Window.location.replace (' url ')

Chinese Simplified
else if (lang = = "ZH-CN")
Window.location.replace (' url ')


Chinese Traditional
else if (lang = = "ZH-TW")
Window.location.replace (' url ')

German
else if (lang = = "de")
Window.location.replace (' url ')


In addition to the languages listed above
Else
Window.location.replace (' url ')

</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.