函数内部变量访问,不能再函数外访问 <html> <head> <title></title> <mce:script type="text/javascript"><!-- alert("a"); var x = 100; function f1( a, b, c){ alert(a); alert(b); alert(c); alert(x); var d = "a"; } f1(1,2,3,4) alert(d);//函数内部的变量不能再函数外访问 // --></mce:script> </head> <body> </body> </html> <mce:script type="text/javascript"><!-- //不用声明形式参数的类型 function doit(a,b,c){ alert(a); alert(b); alert(c); } //以下方式均可调用这个函数! doit(); doit(15); doit(15,16); doit("a",'b',true); doit("a",'b',true,100); // --></mce:script> 简单函数例子 <html> <head> <title></title> <mce:script type="text/javascript"><!-- alert("a"); var x = 100; function f1( a, b, c){ alert(a); alert(b); alert(c); alert(x); } f1(1,"2",3); // --></mce:script> </head> <body> </body> </html> 传入参数可以多或者少于定义的参数个数 <html> <head> <title></title> <mce:script type="text/javascript"><!-- alert("a"); var x = 100; function f1( a, b, c){ alert(a); alert(b); alert(c); alert(x); } f1(1,2,3,4) // --></mce:script> </head> <body> </body> </html>