JS operation Dom object and how to get browser width height

Source: Internet
Author: User
Tags unique id

 Dom is independent of the specific programming language and usually accesses the DOM through JavaScript, but it is not strictly required. You can use any scripting language to access the DOM, thanks to its consistent API.
getElementById (ID) (document) Gets the element with the specified unique ID property value in the document
Getelementsbytagname_r (name) returns an array of child elements in the current element with the specified tag name
HasChildNodes () returns a Boolean value that indicates whether the element has child elements getattribute (name) returns the attribute value of the element, and the attribute is specified by name with the Web-based DOM to write a simple cross-browser script to take full advantage of the powerful functional flexibility of XML Use XML as the communication medium between the browser and the server. with the With the DOM, you can write a simple cross-browser script that takes advantage of the power and flexibility of XML as a mass between the browser and the server.

, page body width and height

Width:document.body.scrollWidth

Height:document.body.scrollHeight

There are documentation statements: IE8 and FF5 Heights may be smaller than the visible area height, Chrome12 is greater than or equal to the visible height

No document declaration: IE8 height may be less than visible area height, FF5 and Chrome12 are greater than or equal to visible area height

Width and height of the visible area of the Web page

Width:document.body.clientWidth

Height:document.body.clientHeight

When a document is declared: Width is the height of the visible area of the Web page, height may be less than the visible height

When no document is declared: Width is the height of the visible area of the Web page, height is greater than or equal to the visible area height

that's how I do it. Dom, how to get the understanding of the DOM object, and how to get the browser's wide understanding, hoping to help everyone.

JS operation Dom object and how to get browser width height

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.