js实现不重复导入的方法


本文实例讲述了js实现不重复导入的方法。分享给大家供大家参考,具体如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>无标题页</title>
  <mce:script src="jquery-1.4.4.js" mce_src="jquery-1.4.4.js" type="text/javascript"></mce:script>
  <mce:script type="text/javascript"><!--
    function importOnce(scriptPath) {
      var scripts = document.getElementsByTagName("script");
      for (var index = 0; index < scripts.length; index++) {
        if (scripts[index].src.lastIndexOf(scriptPath) != -1) {
          return;
        }
      }
      var scriptTag = document.createElement("script");
      scriptTag.type = "text/javascript";
      scriptTag.src = scriptPath;
      var headTag = document.getElementsByTagName("head")[0];
      headTag.appendChild(scriptTag);
    }
    importOnce("jquery-1.4.4.js");
    importOnce("jquery-1.4.4.js");
    importOnce("jquery-1.4.3.js");
    importOnce("jquery-1.4.3.js");
// --></mce:script>
</head>
<body>
</body>
</html>

更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》、《JavaScript遍历算法与技巧总结》及《JavaScript数学运算用法总结》

希望本文所述对大家JavaScript程序设计有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3