HTML文档中含有如下内容:
<form name="register" method="post" action="index.php?action=register">
Name:<input type="text" name="username" />
</form>
通过 javascript 访问此 Form 节点的方式是:
<script type="text/javascript">
window.οnlοad=function(){
// First
alert(document.getElementsByTagName('form').item(0).action);
//Second
alert(document.forms[0].action);
//Third
alert(document.forms.item(0).action)
//Fourth
alert(document.forms.register.action);
//Fifth
alert(document.forms['register'].action)
//Sixth
alert(document.forms.namedItem('register').action);
}
</script>