PHP web pages automatically jump to Chinese and English pages based on different browser languages: http://www.gabion.cn when the visitor browser language is Chinese to enter the Chinese version of foreign users default browser is not Chinese to jump to the English page PHP code :? $ Lansubstr ($ HTTP_ACCEPT_LANGUAGE, 0, 5); if ($ lanzh-cn) print (metah
PHP web pages automatically jump to Chinese and English pages based on different browser languages
Demo: http://www.gabion.cn
When the visitor's browser language is Chinese, the Chinese version is displayed.
Overseas users jump to the English page if the browser is not Chinese by default.
PHP code:
$ Lan = substr ($ HTTP_ACCEPT_LANGUAGE, 0, 5 );
If ($ lan = "zh-cn ")
Print (" ");
Else
Print (" ");
?>
HTML web pages automatically jump to multilingual pages based on different browser languages
In Add the following code.
Script
Var type = navigator. appName
If (type = "Netscape ")
Var lang = navigator. language
Else
Var lang = navigator. userLanguage
// Cut down to first 2 chars of country code
Var lang = lang. substr (0, 2)
// English
If (lang = "en ")
Window. location. replace ('URL ')
// Simplified Chinese
Else if (lang = "zh-cn ")
Window. location. replace ('URL ')
// Traditional Chinese
Else if (lang = "zh-tw ")
Window. location. replace ('URL ')
// German
Else if (lang = "de ")
Window. location. replace ('URL ')
// Except the languages listed above
Else
Window. location. replace ('URL ')
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