zhang-bobo

第一种:

  -使用一个标签<script type="text/javascript">js代码</script>

 1 <!doctype html>
 2 <html lang="en">
 3  <head>
 4   <meta charset="UTF-8">
 5   <meta name="Generator" content="EditPlus®">
 6   <meta name="Author" content="">
 7   <meta name="Keywords" content="">
 8   <meta name="Description" content="">
 9   <title>Document</title>
10  </head>
11  <body>
12     <script type="text/javascript">
13 
14         //向页面弹出一个框,显示内容
15         alert("aaaa");
16     </script>
17  </body>
18 </html>

 

第二种:

  -使用script标签,引入一个外部的js文件

  *** 创建一个js文件,写js代码

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

  ** 使用第二种方式时候,就不要在script标签里面写js代码了,不会执行。

 1 <!doctype html>
 2 <html lang="en">
 3  <head>
 4   <meta charset="UTF-8">
 5   <meta name="Generator" content="EditPlus®">
 6   <meta name="Author" content="">
 7   <meta name="Keywords" content="">
 8   <meta name="Description" content="">
 9   <title>Document</title>
10  </head>
11  <body>
12     <script type="text/javascript" src="1.js">
13         //这里就不要写js代码了
14     </script>
15  </body>
16 </html>

//js文件内容
/*多行注释*/

alert("bbbb");

 

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2022-02-07
  • 2021-04-28
  • 2021-11-20
  • 2022-01-05
  • 2022-12-23
  • 2021-11-30
  • 2021-11-17
猜你喜欢
  • 2021-12-10
  • 2021-12-15
  • 2021-11-22
  • 2021-09-16
  • 2022-12-23
  • 2021-12-10
  • 2021-06-09
相关资源
相似解决方案