国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Code:loadScript( )加載js的功能函數

2019-11-21 02:18:05
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

<script type="text/javascript"> 
/** 
 * function loadScript 
 * Copyright (C) 2006 Dao Gottwald 
 * 
 * This library is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version. 
 * 
 * This library is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * Lesser General Public License for more details. 
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library; if not, write to the Free Software 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 
 * 
 * Contact information: 
 * Dao Gottwald <dao at design-noir.de> 
 * Herltestra?e 12 
 * D-01307, Germany 
 * 
 * @version 1.5 
 * @url http://design-noir.de/webdev/JS/loadScript/ 
 */ 

function loadScript (url, callback) { 
  var script = document.createElement('script'); 
  script.type = 'text/javascript'; 
  /* should be application/javascript 
   * http://www.rfc-editor.org/rfc/rfc4329.txt 
   * http://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=84613 
   */ 
  if (callback) 
    script.onload = script.onreadystatechange = function() { 
      if (script.readyState && script.readyState != 'loaded' && script.readyState != 'complete') 
        return; 
      script.onreadystatechange = script.onload = null; 
      callback(); 
    }; 
  script.src = url; 
  document.getElementsByTagName('head')[0].appendChild (script); 

</script>
 

實例:
復制代碼 代碼如下:
<script type="text/javascript">
// prevent google analytics from slowing down page loading
window.addEventListener ('load', function() {
  loadScript ('http://www.google-analytics.com/urchin.js', function() {
    window._uacct = 'UA-xxxxxx-x';
    urchinTracker();
  });
}, false);
</script>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 金溪县| 汉中市| 淳安县| 苍梧县| 江津市| 新巴尔虎右旗| 金山区| 和田县| 卓尼县| 沙湾县| 紫金县| 乃东县| 北安市| 定陶县| 宁德市| 游戏| 蓬溪县| 安达市| 博乐市| 贵阳市| 陇西县| 永新县| 商都县| 定结县| 舟山市| 全椒县| 波密县| 密云县| 大厂| 福建省| 讷河市| 莱州市| 五原县| 富阳市| 富蕴县| 平陆县| 阳曲县| 密山市| 化州市| 社会| 怀安县|