Javascript: Get the available width of the browser window and screen

Source: Internet
Author: User

1. Get the effective width of the browser window (excluding toolbars and scroll bars)

Note: For most browsers use window.innerwidth to get width, use document.documentElement.clientWidth | | Document.body.clientWidth in order to achieve support for ie6,7.

Height ibid.

var w=window.innerwidth |  | document.documentElement.clientWidth  | | document.body.clientWidth;  var h=window.innerheight |  | document.documentElement.clientHeight  | | document.body.clientHeight;  X=document.getelementbyid ("Screen_size");  X.innerhtml= "Browser's internal window width:" + w + ", Height:" + H + ". "

2. Get the effective width of the screen

document.write ("Screen available size, Width:" + screen.availwidth+ ", High:" +screen.availheight);

3.location related (get Web server related information)

    document.write ("Domain name of the web host:" +location.hostname+ "<br/>");    document.write ("Path and file name of the current page:" +location.pathname+ "<br/>");    document.write ("Port for web host:" +location.port+ "<br/>");    document.write ("Web protocol used:" +location.protocol+ "<br/>");    document.write ("URL of the current page:" +location.href+ "<br/>");



Javascript: Get the available width of the browser window and screen

Related Article

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.