The UniqueID in HTML

Source: Internet
Author: User

The Name property of the element on the Web page itself can be duplicated, in theory the ID can not be duplicated, but now the browser to duplicate ID is tacit, perhaps sometimes the page needs a unique number. IE browser for all elements on the page is provided with a unique name--uniqueid, which has the following characteristics:

1. Using the lazy initialize technology, which is generated when access

2. ID Format: ms__id\d+

The original article is as follows:

Each HTML element in a Web page has an id attribute, and the ID as its label, which should be unique in our general understanding. However, the id attribute of the HTML element is writable, which makes it possible for us to artificially duplicate the ID. What if the ID repeats? How do we get a unique label for the HTML element?

Because of the excellent fault tolerance of the HTML code for IE's chaotic format (incomplete or faulty nesting relationships), the repetition of the ID of the HTML element is a piece of cake for it. If this happens, for example:

<</span>div id= "Divtext" >the first line.</</span>div>
<</span>div id= "Divtext" >the second line.</</span>div>

The Divtext is not a reference to the DIV element, but an array of two elements, sorted by the sequence of two DIV elements that appear in the DHTML object Tree.

How to use such an ID AH? Do you feel like a little bit by IE?!

Fortunately, ie precipice provides a UniqueID read-only property for HTML elements after 5.0.  This is good, to make it into a readonly, see ya still disorderly?! Fortunately really not disorderly, but how to say this UniqueID interesting? Since UniqueID itself does not provide the default value, IE will not assign UniqueID to HTML elements after parsing the HTML code to build the DHMTL tree. This UniqueID value is generated only after we have visited the UniqueID property of the HTML element. In fact, it is lazy initialize technology, just put here feel more fun. For Uniquenumber, it is relative to UniqueID, and the UniqueID format is: ms__id\d+. That is, a "ms__id" prefix plus a serial number. So this uniquenumber is a separate indication of that running number.

UniqueID The second interesting place is that the Document object also has this property, but it is completely different from the other HTML UniqueID properties. When we call Document.uniqueid every time, the system returns a new UniqueID value, but Doucment does not have a Uniquenumber attribute ha.

The UniqueID in HTML

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.