javascript函数

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

<!--一、函数-->

<script>

function hanshu()

{

    document.write("欢迎")

}

</script>



<!--二、带参数的函数-->

<script>

function canshu(txt)

{

alert(txt)    

}

</script>



<!--三、带返回值的函数-->

<script>

function fanhui()

{

    return ("wwz")

}

</script>



<!--四、带有返回值并带有参数的函数-->

<script>

function chengfa(a,b)

{

    return(a*b)

    }

</script>

</head>



<body>

<!--一、函数-->

<input type="button" onclick="hanshu()" value="调用">

<!--二 、带参数的函数-->

<input type="button" onclick="canshu('参数')" value="调用参数">

<!--三、带返回值的函数-->

<script>

document.write(fanhui())

</script>



<!--四、带有返回值并带有参数的函数-->

<script>

document.write(chengfa(5,6))

</script>





</body>

</html>

 

你可能感兴趣的:(JavaScript)