首先建立一个脚本文件,内容如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Just a test</title>
</head>
<body>
<script src="example.js"></script>
</body>
</html>
另存为test.html文件。
再建立一个脚本,内容如下
var="Hello World"
alert(var);
另存为example.js文件。
最后将test.html文件拖入浏览器显示。