Home > Web Front-end > JS Tutorial > body text

JS gets the browser language and dynamically loads the JS file sample code_javascript skills

WBOY
Release: 2016-05-16 16:32:22
Original
1277 people have browsed it

For the sake of multi-language version, the project uses easyui at the front end. By getting the browser language version, the easyui language package is loaded relatively. The default language package of easyui is en-US

The code is as follows

<script type="text/javascript"> 
//ie 
if (navigator.browserLanguage != "undefined" && navigator.browserLanguage != null) { 
if (navigator.systemLanguage == "zh-CN") { 
document.write("<script src='jquery-easyui/locale/easyui-lang-zh_CN.js'><\/script>"); 
} 
} 
//firefox、chrome,360 
else { 
if (navigator.language == "zh-CN") { 
document.write("<script src='jquery-easyui/locale/easyui-lang-zh_CN.js'><\/script>"); 
} 
} 
</script> 
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template