The most common compatibility problems that dom| access to Web browsers, such as Firefox and other gecko engines, are the differences between IE DHTML and the consortium DOM.
One of the easiest bugs in nonstandard DHTML scripts is to use an irregular way to access page elements. We have used spider to climb some well-known domestic portal sites, in terms of quantity, more than 95% of the JavaScript errors come from this.
Common ways to access page elements are not standardized:
1. Access the page element directly with the ID or Name property name, for example:
The right thing to do is to use getElementById to come to an element with an id attribute, using Getelementsbyname to get some element with the name attribute. For example, the above code can be changed to:
The specified ID in the HTML standard must be unique in a Web page, and if you want to access a set of elements at once, you can use the Name property for elements that support the name attribute, and name can be unique. The above example can be read as follows:
Someone's been writing for a lifetime. DHTML doesn't know what the difference is between ID and name, because IE never helped them understand it. Do you thank IE for "compatibility"? I don't.
3. Use the All property, such as document.all, to access the page elements. The All property is a proprietary property of IE DHTML that can be accessed by accessing the page elements in the following ways:
The standard practice is to use getElementById or getelementsbyname.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.