JS gets the sample code for dynamically loading JS files in the browser language

  • 2020-03-30 04:15:48
  • OfStack

Considering the multi-language version of the project, the foreground USES easyui to relatively load the easyui language package by obtaining the browser language version. The default language package of easyui is en-us

The following code


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

Related articles: