`
f002489
  • 浏览: 265078 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
一个能动态加载js的方法 jquery 哈哈找到一个能动态加载js的方法
var head = document.getElementsByTagName("head")[0] ||        
                             document.documentElement;
    var script = document.createElement("script");
    script.src = s.url;
    // Handle Script loading
    // Attach handlers for all browsers
    script.onload = script.onreadystatechange = function() {
         if ( !done && (!this.readyState ||
                     this.readyState === "loaded" || this.readyState === "complete") ) {
             done = true;
             jQuery.handleSuccess( s, xhr, status, data );
             jQuery.handleComplete( s, xhr, status, data );
             // Handle memory leak in IE
             script.onload = script.onreadystatechange = null;
             if ( head && script.parentNode ) {
                 head.removeChild( script );
              }
           }
        };
 }
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
 // This arises when a base node is used (#2709 and #4378).
 head.insertBefore( script, head.firstChild );
 // We handle everything using the script element injection
return undefined;

Global site tag (gtag.js) - Google Analytics