<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>index</title>
</head>
<body>
<!--1、行内JS-->
<button onclick="alert('aaa');">点我</button>
<a href="javascript:alert('aaa');">点我</a>
<!--2、页内JS-->
<script type="text/javascript">
window.onload = function(){
alert("aaa");
}
</script>
</body>
</html>
3、外部JS
需要通过src属性引入<script type="text/javascript" src = ""></script>