1.javascript语句直接调用
2.在事件中调用
3.在超链接中调用
<html>
<head>
<title>
javascript demo
</title>
<script language="JavaScript" type="text/javascript">
function myfun()
{
alert("show alert,ok!");
form1.textBox1.value=eval(form1.textBox1.value)+eval(6);
}
function myfun2(){
document.write("hello ,use document to write content");
}
function myfun3(){
alert("call function in myfun3");
myfun();
}
myfun3();
</script>
</head>
<body>
<form name="form1" action="">
<input type="text" name="textBox1"value="1"></input>
<input type="button" value="click me" onclick=myfun()>
<br>
<a href=javascript:myfun2()>call myfun2</a>
</form>
</body>
</html>
本文通过一个HTML页面示例介绍了三种JavaScript函数调用的方法:直接调用、作为事件处理程序调用以及通过超链接调用。示例展示了如何使用这些方法来改变页面上的元素值并显示提示框。
2万+

被折叠的 条评论
为什么被折叠?



