JS Operation Dom and get browser height and width

Source: Internet
Author: User
Tags tag name unique id

In JavaScript, it is often necessary to get the document element, which is an abbreviation for the HTML Document Object model, which defines a series of standard objects for HTML and a standard way to access and manipulate HTML documents.

  

Through the DOM, you can access all the HTML elements, along with the text and attributes they contain. You can modify and delete the content, and you can also create new elements. The HTML DOM is independent of the platform and programming language. It can be used by any programming language such as Java, JavaScript, and VBScript.

ChildNodes returns an array of all child elements of the current element, Firschild return the first subordinate child element of the current element, LastChild back to the last child element of the current element, NextSibling returns the element immediately following the current element. NodeValue the Read/write property of the specified TABLE element parentnode specifies that the parent node of the element previoussibling return the element immediately preceding the current element.

document.getElementById is the element that gets a document that has the specified unique id attribute value. Document.getelementbytagname returns an array of child elements in the current element with the specified tag name, HasChildNodes () returns a Boolean value indicating whether the element has child elements, Document.getelementbycclassname is to get the class name element in the document, Document.getelementsbyname (elementname): Gets the node by name, as you can see from the name, Instead of a node element, this method returns an array of nodes with the same name. We can then loop through a property of the node to determine whether it is a required node.

If you want to get the width of your browser, here are a few ways:

1. Get the width of the visible area of the webpage: document.body.clientWidth;

2. Get the height of the visible area of the webpage: document.body.clientHeight;

3. Get the width of the visible area of the webpage: document.body.offsetWidth; (including the width of the edge)

4. Get the page visible area High: Document.body.offsetHeight;(including the width of the edge)

5. Get the full text width of the Web page: document.body.scrollWidth;

6. Get the full text of the Web page High: document.body.scrollHeight;

7. Get the page to be rolled High: document.body.scrollTop;

8. Get the page to be rolled left: document.body.scrollLeft;

9. Get the body part of the webpage: window.screentop;

11. Get the page body part left: window.screenleft;

12. Get the high screen resolution: window.screen.height;

13. Get the width of the screen resolution: Window.screen.width;

14. Screen available work area height: window.screen.availHeight

15. Screen available work area width: window.screen.availWidth

JS Operation Dom and get browser height and width

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.