JS obtains the sample code of the JS file dynamically loaded by the browser language. js sample code

Source: Internet
Author: User

JS obtains the sample code of the JS file dynamically loaded by the browser language. js sample code

For the multi-language version of the project, easyui is used in the foreground to obtain the browser language version to load the easyui Language Pack. The easyui default language pack 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>

How to obtain the js files on the page loaded by the browser

In IE cache, you can also find the path to download from the source file code.

Dynamic Loading of JS files and functions

Ie seems to be like this. If the call is unsuccessful, it means that onload is executed before the script is loaded. (The requests dynamically generated by ie may not be added to the Request queue that affects onload ), you can monitor the onload events of dynamically created script labels. ie seems to be oncomplete and onreadystatechange. After loading, add a loaded identifier and call

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.