Javascript precautions for finding controls in the Netscape Browser

Source: Internet
Author: User

In IE and other browsers, we can use document. All. controlid to find the control whose ID is controlid. Of course, we can also use document. getelementbyid ('controlid') to find the control;
However, in netscape6 or later versions, document must be used. getelementbyid (). Otherwise, the script may fail to run normally, and hope this experience will be helpful to anyone who wants to support the Netscape control.

Supplement:
After reading using JavaScript, we found that this is related to the DOM model of the browser.
W3C DOM: Document. getelementbyid ("controlid ")
Ie4: Document. All. controlid
Netscape4: Document. layers. controlid

******************************** Updated on 2005.7.31 **** **************************
If only the name attribute is set for the control, but the ID attribute is not set, document. getelementbyid can be found, but document is used in Netscape. getelementid cannot be found. You must add an ID for this control.
Note: When registerhiddenfield of. Net registers a type = hidden input, the ID is not automatically generated, and only the name is generated. Therefore, if you want
Find this control in Netscape by searching for document. getelementsbyname ('controlid') [0 ].
Registerhiddenfield: Use response. Write to forcibly write a hidden to your page.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.