玩法介绍当前位置:鸿宇娱乐 > 玩法介绍 > >

鸿宇娱乐:异步加载JS、CSS代码(推荐)

  

[异步加载js,css]异步加载JS、CSS代码(推荐)

  

我的风格你懂得,具体详情介绍如下  

  

关键代码如下所示:  
  

  
  
  function AsyncLoad(V_tag,V_src)  {  if (V_tag == "script") {  var s = document.createElement('script');  s.type = 'text/javascript';  s.async = true;  s.src = V_src;  var x = document.getElementsByTagName('script')[0];  x.parentNode.insertBefore(s, x);  s.onload = function () {  if (V_src == "../Content/Scripts/jquery-2.1.1.min.js") {  AsyncLoad("script", "../Content/Scripts/public-effect.js");  AsyncLoad("script", "../Content/Scripts/d3.v3.min.js");  AsyncLoad("script", "../Content/Scripts/Common.js");  AsyncLoad("script", 鸿宇娱乐平台 "../Content/Scripts/mobilePie.js");  }  if (V_src == "../Content/Scripts/d3.v3.min.js")  {  AsyncLoad("script", "../Content/Scripts/Ticket/MyPCs.js");  }  }  } else {  var s = document.createElement('link');  s.async = true;  s.rel = "stylesheet"  s.href = V_src;  var x = document.getElementsByTagName('link')[0];  x.parentNode.insertBefore(s, x);  s.onload = function () {  }  }  }  window.onload = function () {  AsyncLoad("link", "../Content/stylesheets/swiper-3.2.7.min.css");  AsyncLoad("script", "../Content/Scripts/jquery-2.1.1.min.js");  AsyncLoad("script", "../Content/Scripts/swiper-3.2.7.jquery.min.js");  }
  
  

  

(责任编辑:admin)

上一篇:鸿宇娱乐平台:jquery简单瀑布流实现原理及ie8下

下一篇:鸿宇娱乐:JavaScript是否可实现多线程 深入理解

推荐内容

客户服务热线

010-400-12345

在线客服