javascript link code example

Example 1: link javascript to html

<script src="index.js"> </script>

Example 2: link javascript html

<script type="text/javascript" src="monscript.js"></script>

Example 3: how to link js to html

<script src="Your-JavaScript-File.js"></script> <!--If JS file is in same folder with HTML file-->

Example 4: javascript link in html

<script type="text/javascript" src="./der/pfad/zu/der/datei.js"></script>

Example 5: how to link javascript to html

<script src = "index.js"></script>

Example 6: create a link javascript

<html>
  <head></head>
  <body>
    <script>
      var a = document.createElement('a');
      var linkText = document.createTextNode("my title text");
      a.appendChild(linkText);
      a.title = "my title text";
      a.href = "http://example.com";
      document.body.appendChild(a);
    </script>
  </body>
</html>