zoukankan      html  css  js  c++  java
  • 动态引入Js文件

        var src = "/Scripts/Test.js";  
        $("<script type = 'text/javascript' src='" + src + "'></script>").appendTo("head");  //动态加载
        TestAlert123123();   //调用Test.js中的函数

    二、顺序添加(QQ)

      <img src="1.jpg" width="200" height="300" />
         <script src="jquery/jquery-1.4.1.js" type="text/javascript"></script>
         <script src="js/hello.js" type="text/javascript"></script>
         <script src="js/world.js" type="text/javascript"></script>
    
         <script type="text/javascript">
             function loadScript(url, callback) {
                 var script = document.createElement("script");
                 script.type = "text/javascript";
     
                 //IE
                 if (script.readyState) {
                     script.onreadystatechange = function () {
                         if (script.readyState == "loaded" || script.readyState == "complete") {
                             script.onreadystatechange = null;
                             callback();
                         }
                     }
                 } else {
                     //非IE
                     script.onload = function () {
                         callback();
                     }
                 }
                 script.src = url;
                 document.getElementById("head").appendChild(script);
             }
             //第一步加载jquery类库
             loadScript("jquery/jquery-1.4.1.js", function () {
                 //第二步加载hello.js
                 loadScript("js/hello.js", function () {
                     //第三步加载world.js
                     loadScript("js/world.js", function () {
     
                     });
                 });
             });
         </script>
  • 相关阅读:
    python3(二十七)property
    python3(二十六)slots
    python3(二十五) getClassInfo
    python3(二十四) subClas
    python3(二十三)classInstance
    python3(二十二) oop
    python3(二十一) pip
    python3(二十) module
    python3(十九)Partial func
    python3(十八)decorator
  • 原文地址:https://www.cnblogs.com/gossip/p/3796016.html
Copyright © 2011-2022 走看看