Home > Web Front-end > JS Tutorial > body text

js method to achieve non-repeated import_javascript skills

WBOY
Release: 2016-05-16 15:12:35
Original
1303 people have browsed it

The example in this article describes the method of non-repeated import in js. Share it with everyone for your reference, the details are as follows:

<!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>

Copy after login

Readers who are interested in more JavaScript-related content can check out the special topics on this site: "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation special effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript traversal algorithms and techniques" and "JavaScript Mathematics Summary of operation usage

I hope this article will be helpful to everyone in JavaScript programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template