外部js文件
//输出到浏览器控制台的代码
console.log("Hello World !");
//显示消息窗口
alert("hello world !");
//显示到浏览器的文档区
document.write("hello world !");
HTML文件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>引用外部文件js文件</title>
</head>
<body>
<!--以下几种声明编辑规范都是一样的-->
<!--<script type="text/javascript"></script>*/-->
<!--<script type="application/javascript"></script>-->
<!--
脚本内联写法
//输出到浏览器控制台的代码
console.log("Hello World !");
//显示消息窗口
alert("hello world !");
//显示到浏览器的文档区
document.write("hello world !");
-->
<!--
外部js脚本文件
-->
<!--js必须写到script块中 -->
<!--这里我们要注意,在js里头,我们一定要给空标记写结束标记。
即要写完整的一对,否则src找不到外部文件。
我们引用外部文件的标签中间,就不要再写内容了,否则会有错误。
-->
<script type="text/javascript" src="../js/js1.js"></script>
</body>
</html>
