国产探花免费观看_亚洲丰满少妇自慰呻吟_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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 山西省| 沁阳市| 桦南县| 保山市| 通江县| 尉氏县| 缙云县| 大田县| 栾川县| 丹江口市| 土默特左旗| 即墨市| 宣城市| 铁岭县| 上栗县| 牙克石市| 三河市| 阆中市| 漳浦县| 县级市| 定边县| 永安市| 京山县| 海淀区| 竹山县| 柳江县| 马尔康县| 阿克苏市| 大丰市| 修水县| 三江| 辽阳县| 乌海市| 保德县| 九龙城区| 秦安县| 和龙市| 梓潼县| 乌鲁木齐县| 湛江市| 大足县|