function message(){ alert("调用JS函数!sum(100,200)="+sum(100,200)); } function sum(x,y){ return x+y; }
<html> <head> <title>head中定义的JS函数</title> </head> <body> <h4>head标记内定义两个JS函数</h4> <p>无返回值函数:message()</p> <p>有返回值函数:sum(x,y)</p> <form action=""> <input type="button" onclick="message()" value="计算并显示两个数的和"> </form> </body> </html>