Javascript学习笔录5(Javascript 函数怎么玩)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Js3.aspx.cs" Inherits="Javascript_Js3" %>

<!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 runat="server">
    <title>Untitled Page</title>
    <script>
    //定义函数
    function quote()
    {
        document.write("quote 定义函数")
    }
    //任何不用 var关键字声明的变量都是全局变量,任何在函数外声明的变量都是全局变量
    //传参数的函数.写在头里面,就先编译了撒
    function cute(item)
    {
        document.write("输出参数"+item+"</br>")
    }
    //而且cute函数有调用
    cute(111)
    cute("2cute")
    //返回值函数
    function average(var1,var2,var3)
    {
        ave=(var1+var2+var3)/3
        document.write("输出结果")
        return ave
    }
    document.write(average(1,2,3))
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type="button" name="btn1" value="Quote" onclick=quote() />
    <br />
    <a href=javascript:quote()>通过HTML链接调用函数</a></br>
    <a href=javascript:document.write("页面用response.write,js用document.write.")>通过HTML链接调用函数,直接写Javascript语句</a>
    </div>
    </form>
</body>
</html>

你可能感兴趣的:(JavaScript,html,server,function,XHTML,button)