日期:2014-05-16  浏览次数:20398 次

新手求指导,关于函数调用
JScript code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtmll/DTD/xhtmll-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>form表单</title>
<script type="text/javascript">
    function window_onload()
    {
        var numberForms=document.forms.length;
        var formIndex;
        for(formIndex=0;formIndex<numberForms;formIndex++)
        {
            alert(document.forms[formIndex].name;
        }

    }
</script>

</head>
<body onload="window_onload()">
<form action=" " name="form1">
    <p>
        this is inside form1
    </p>

</form>
<form action=" " name="form2">
    <p>
        this is inside form2
    </p>

</form>
<form action=" " name="form3">
    <p>
        this is inside form3
    </p>

</form>
</body>
</html>





调试报错:"window_onload()"未定义,求解释

------解决方案--------------------
alert(document.forms[formIndex].name);
少写一反括号,代码错误 所以报函数未定义