Dom and BOM

Source: Internet
Author: User

Dom

1. Concept Origin:

Document Object Model (DOM) is a standard programming interface recommended by W3C for processing Extensible Markup Language. On a webpage, objects on an organizational page (or document) are organized in a tree structure. The standard model used to represent objects in a document is called Dom. The history of the Document Object Model can be traced back to the "browser war" between Microsoft and Netscape in the late 1990 s. The two sides decided to survive and survive JavaScript and JScript, so they granted powerful functions to the browser on a large scale. Microsoft has added a lot of exclusive transactions in Webpage technology, including VBScript, ActiveX, and Microsoft's DHTML format, which makes it impossible for many webpages to be displayed normally on non-Microsoft platforms and browsers. Dom is the masterpiece developed at that time.

2. Method:

Use the getelementbyld () and getelementsbytagname () Methods

Use the parentnode, firstchild, and lastchild attributes of an element node

Getelementbyld () and getelmementstagname () can be used to find any HTML element in the entire HTML document.

The two methods ignore the structure of the document. These two methods will provide you with any HTML elements you need, regardless of their location in the document.

Getelementbyld () can return elements through the specified ID:

Getelementbyld () syntax

Document. getelementbyld ("ID"); Note: getelementbyld () cannot work in XML. In XML documents, you must search by the property with the type ID, And this type must be declared in xmldtd.

The getelementsbytagname () method returns all elements (as a node list) using the specified tag name.

The descendant of the element in which this method is used.

Getelementsbytagname () can be used for any HTML element:

Getelementsbytagname () syntax

Document. getelementsbytagname ("tag name"); or:

Document. getelementbyid ('id'). getelementsbytagname ("tag name ");

3. content:

 

 

4. Application: Process Extensible Markup Language

Dom, a Document Object Model, is a standard interface specification developed by W3C and a standard API for processing HTML and XML files. Dom provides an access model for the entire document, which uses the document as a tree structure. each node in the tree represents a text item in an HTML Tag or tag. The DOM tree structure accurately describes the correlations between tags in HTML documents. The process of converting an HTML or XML document into a DOM tree is called parsing (PARSE ). After an HTML document is parsed, it is converted to a DOM tree. Therefore, you can perform operations on the DOM tree to process the HTML document. The Dom model not only describes the structure of the document, but also defines the behavior of the Node object, using the methods and attributes of the object, you can easily access, modify, add, and delete the nodes and content of the DOM tree.

BOM

1. Concept Origin:

BOM (byte order mark) is a byte sequence mark that appears in the header of a text file. It is used in the Unicode encoding standard to identify the encoding format of the file.

Bom -- byte order mark,Translated as"Byte orderMark". Here is a description of BOM:

There is a file named"Zero Width no-break Space", Translated as"Zero-width uninterrupted IntervalIt is encoded as feff. Fffe does not exist in the UCs, so it should not appear in actual transmission. We recommend that you transmit the character "Zero Width no-break space" before transmitting the byte stream in the UCS specification ". In this way, if the receiver receives feff, it indicates that the byte stream is big-Endian; if it receives fffe, it indicates that the byte stream is little-Endian. Therefore, the character "Zero Width no-break space" ("Zero Width uninterrupted interval") is also called Bom.

2. Method:

Objects in Javascript do not exist independently. objects and objects have hierarchies. For example, a document object is a sub-object of a window object and a window object is a document object, which indicates the entire browser window.

Document Object

Document Object: This object represents the document loaded in the browser window. You can use the document object to operate on the content in the document. In the entire Bom, only document objects are related to the content of HTML documents.

Frames array: This array represents the framework in the browser window. HTML allows a browser window to be divided into multiple frameworks, each of which can load an HTML document. In this frame page, each frame is an element in the frames array. Each element in the frames array is a window object.

History Object: This object represents the browsing history of the current browser window. This object allows you to forward or backward a document in the current browser window to a URL that has been accessed (Uniform Resource Locator ).

Location object: This object represents the URL of the current document. The URL is divided into several parts, such as the Protocol, host, and port. You can use the location object to obtain these parts separately and modify the values of these parts to load a new document.

Navigator object: This object is a browser object that represents the browser information. Unlike the window object, the window object can be used to control some properties of the browser window, such as the browser window size and position. The navigator object contains information about the browser, such as the browser name and version number.

Screen Object: This object represents the information of the current display. The screen object can be used to obtain the resolution, available color quantity, and other information of the user's display.

3. content:

4. Application:

Bom is the abbreviation of browser Object Model (Browser object model). It has the following functions:

1. Pop up a new browser window, move it, close the browser window, and adjust the window size;

2. Navigation Objects that provide detailed information about Web browsers;

3. Provides positioning objects loaded to detailed information on pages in the browser;

4. screen objects that provide detailed information about the user's screen resolution;

5. Support for cookies.

 

Dom and BOM

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.