1.使用标签<script>,直接在此标签内写入js的代码
<script>
alert("良言");
</script>
2. 引入外部的js文件
<html>
<head>
<title>html示例</title>
</head>
<body>
<script type="text/javascript" src="1.js">
</script>
</body>
</html>
<script>
alert("良言");
</script>
<html>
<head>
<title>html示例</title>
</head>
<body>
<script type="text/javascript" src="1.js">
</script>
</body>
</html>