简单的调用
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>函数的简单应用</title>
<script type="text/javascript">
function print(statement1,statement2,statement3){
alert(statement1+statement2+statement3);
}
</script>
</head>
<body>
<script type="text/javascript">
print("第一个JavaScript函数程序 ","作者:","wsy");
</script>
</body>
</html>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a7035844af929cf4de094725b4f3c67b.png)
在超链接中调用JavaScript函数
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>在超链接中调用JavaScript函数</title>
<script language="javascript">
function text(){
alert("欢迎点击我!");
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<a href="javascript:text();">点我啊!</a>
</form>
</body>
</html>
在按钮事件中调用JavaScript函数
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>在按钮事件中调用JavaScript函数</title>
<script language="javascript">
function text(){
alert("欢迎点击我!");
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<input type="button" name="Submit" value="普通按钮" onClick="text();" />
</form>
</body>
</html>