HTML imports JS files

To summarize, here are some commonly used ways to introduce js code:

1. Introduction of the page header (within the head tag);

2. Introduced into the page (within the body tag);

3. Introduce external JS files;

1. Introducing JS into the header of the page

<!DOCTYPE html>
<html>

<head>
    <title></title>
    <script type="text/javascript">
         //这里编写JavaScript程序
    </script>
</head>

<body>
</body>

</html>

2. Introduce JS into the page

<!DOCTYPE html>
<html>

<head>
    <title></title>
</head>

<body>
    <script type="text/javascript">
          //这里编写JavaScript程序
    </script>
</body>

</html>

3. Introduce external JS files

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

Guess you like

Origin blog.csdn.net/weixin_46774901/article/details/129822732