Home  >  Article  >  Web Front-end  >  JS gets the browser language and dynamically loads the JS file sample code_javascript skills

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

WBOY
WBOYOriginal
2016-05-16 16:32:221232browse

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> 
Statement:
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