全文如下:
DOM level 0 support access form controls via such script:
var f = document.forms[0];
var control1 = f['controlNameOrId'];
var control2 = f.controlNameOrId;
Though DOM HTML spec provide HTMLFormElement.elements to replace this approach,
but MSIE and Firefox still remain this problematic feature.
The issue here is named control may override the attribute or method of
HTMLFormElement. For example, if there is in the form,
then document.forms[0].action will return that HTMLInputElement. And there is a
bizarre behavior in firefox that assign still works
the 1st line is ok in Firefox(but failed in MSIE), but I find no way to
retrieve it back. the 2nd line will alert false, but u still submit to
http://url (if there is no control named 'submit'
Such behavior is undocumented (maybe i missed...), and will confuse developers
if they unfortunately meet some controls named 'method', 'length', 'id',
'item'(IE only), 'target', 'elements'...
To make the script works, especially when you write a reused component or
script library, there should be no such uncontrolled name conflict. But in most
case the web page is written by designer who has no concern about script, so
it's hard to avoid such case. And, even a script master won't remember all
attribute/method of HTMLFormElement.
As a conclusion, form['controlName'] approach should be removed or limited(ie.
won't override the attribute/method of HTMLFormElement).
public interface IStack<T> {
//元素出栈,并返回出栈元素
public T pop();
//元素入栈
public void push(T element);
//获取栈顶元素
public T peek();
//判断栈是否为空
public boolean isEmpty