<!DOCTYPE HTML>
<html>
<head>
<title>在html中引入js</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<!--第一种方式-->
<script type="text/javascript">
/*定义函数*/
function fn1(){
//弹出提示框
alert("abc")
}
</script>
<!--第二种方式-->
<script type="text/javascript" src="1.js"></script>
</head>
<body>
<input type="button" value="按钮" οnclick="fn2()"/>
</body>
</html>
js文件:
function fn2(){
alert("小子,你还真敢点!")
}