Can any one explain what is the difference between
document.all
and the
document.forms[0] please?
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
document.allgives you a reference to an array-like object containing all elements of the document in Internet Explorer (IE).Document.forms[0]gives you a pointer to the first form element in the document, in all browsersThe 2 are quite different then. If your form had a name attribute, say ‘myform’, then in IE that form could be referenced with
document.all.myformdocument.allis deprecated from IE version 5 and up. You can still use it though, even in IE9 it’s still available. Often it’s used to test if the browser is IE:Referencing forms in the form of
document.forms[0]is considered bad practice. More on that can be found hereNOTE: Since this answer was first written IE11 has been introduced which dropped support for document.all See Compatibility changes in IE11 for more information