JavaScript函数调用方式:简单调用+在超链接中调用JavaScript函数+在事件中调用JavaScript函数

2023-05-16

简单的调用

<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");	//在页面中调用print()函数
	</script>
</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="">
		<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JavaScript函数调用方式:简单调用+在超链接中调用JavaScript函数+在事件中调用JavaScript函数 的相关文章

随机推荐