


JavaScript window width and height, mouse position, scroll height (detailed analysis)_Basic knowledge
Width of the visible area of the web page: document.body.clientWidth
Height of the visible area of the web page: document.body.clientHeight
Width of the visible area of the web page: document.body.offsetWidth (including the width of the edges)
Height of the visible area of the webpage: document.body.offsetHeight (including the width of the edge)
Full text width of the webpage body: document.body.scrollWidth
Height of the full text of the webpage body: document.body.scrollHeight
The webpage is scrolled The height: document.body.scrollTop
The left side of the webpage being scrolled: document.body.scrollLeft
The top part of the webpage body: window.screenTop
The left side of the webpage body part: window.screenLeft
Screen resolution The height of the screen resolution: window.screen.height
The width of the screen resolution: window.screen.width
Screen available work area height: window.screen.availHeight
Screen available work area width: window.screen. availWidth
HTML precise positioning: scrollLeft, scrollWidth, clientWidth, offsetWidth
scrollHeight: Get the scroll height of the object.
scrollLeft: Sets or gets the distance between the left edge of the object and the leftmost end of the currently visible content in the window
scrollTop: Sets or gets the distance between the topmost edge of the object and the topmost end of the visible content in the window
scrollWidth: Get the scroll width of the object
offsetHeight: Get the height of the object relative to the layout or the parent coordinate specified by the offsetParent property
offsetLeft: Get the height of the object relative to the layout or the parent coordinate specified by the offsetParent property Calculate the left position
offsetTop: Get the calculated top position of the object relative to the layout or the parent coordinate specified by the offsetTop attribute
event.clientX The horizontal coordinate relative to the document
event.clientY The vertical coordinate relative to the document
event.offsetX is the horizontal coordinate relative to the container
event.offsetY is the vertical coordinate relative to the container
document.documentElement.scrollTop is the value of vertical scrolling
event.clientX document.documentElement.scrollTop is relative to the horizontal position of the document The amount of vertical scrolling of coordinates
The differences between IE and FireFox are as follows:
IE6.0, FF1.06:
clientWidth = width padding
clientHeight = height padding
offsetWidth = width padding border
offsetHeight = height padding border
IE5.0/5.5:
clientWidth = width - border
clientHeight = height - border
offsetWidth = width
offsetHeight = height
(It needs to be mentioned: the margin attribute in CSS has nothing to do with clientWidth, offsetWidth, clientHeight, and offsetHeight)
-----------------
The code in this section mainly uses some properties of the Document object regarding the window. The main functions and usage of these properties are as follows.
To get the size of the window, different properties and methods need to be used for different browsers:
To detect the real size of the window, you need to use the properties of Window under Netscape;
Under IE, you need to go deep inside the Document to detect the body;
In the DOM environment, if you want to get the size of the window, you need to pay attention to the size of the root element, not the element.
The innerWidth property of the Window object contains the inner width of the current window.
The innerHeight property of the Window object contains the inner height of the current window.
The body attribute of the Document object corresponds to the tag of the HTML document.
The documentElement property of the Document object represents the root node of the HTML document.
document.body.clientHeight represents the current height of the window where the HTML document is located.
document.body.clientWidth represents the current width of the window where the HTML document is located.
Implementation code:
Please resize the browser window
Source program interpretation
(1) The program first creates a form containing two text boxes to display the current width and height of the window, and their values will change as the window size changes.
(2) In the subsequent JavaScript code, two variables winWidth and winHeight are first defined to save the height and width values of the window.
(3) Then, in the function findDimensions (), use window.innerHeight and window.innerWidth to get the height and width of the window, and save them in the two aforementioned variables.
(4) Then detect the body by going deep into the Document, obtain the window size, and store it in the two variables mentioned above.
(5) At the end of the function, by accessing the form elements by name, the results are output to two text boxes.
(6) At the end of the JavaScript code, complete the entire operation by calling the findDimensions () function.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This article will introduce how to turn off the thumbnail function displayed when the mouse moves the taskbar icon in Win11 system. This feature is turned on by default and displays a thumbnail of the application's current window when the user hovers the mouse pointer over an application icon on the taskbar. However, some users may find this feature less useful or disruptive to their experience and want to turn it off. Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another drawback is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. but

According to news from this website on March 31, HP recently launched a Professor1 three-mode Bluetooth mouse on JD.com, available in black and white milk tea colors, with an initial price of 99 yuan, and a deposit of 10 yuan is required. According to reports, this mouse weighs 106 grams, adopts ergonomic design, measures 127.02x79.59x51.15mm, has seven optional 4000DPI levels, is equipped with a Blue Shadow RAW3220 sensor, and uses a 650 mAh battery. It is said that it can be used on a single charge. 2 months. The mouse parameter information attached to this site is as follows:

According to news from this site on July 12, Razer today announced the launch of the Razer|Pokémon Gengar wireless mouse and mouse pad. The single product prices are 1,299 yuan and 299 yuan respectively, and the package price including the two products is 1,549 yuan. This is not the first time that Razer has launched Gengar co-branded peripheral products. In 2023, Razer launched the Gengar-style Yamata Orochi V2 gaming mouse. The two new products launched this time all use a dark purple background similar to the appearance of the Ghost, Ghost, and Gengar families. They are printed with the outlines of these three Pokémon and Poké Balls, with the character Gengar in the middle. A large, colorful image of a classic ghost-type Pokémon. This site found that the Razer|Pokémon Gengar wireless mouse is based on the previously released Viper V3 Professional Edition. Its overall weight is 55g and equipped with Razer’s second-generation FOC

Many users don't know where the files installed by their Razer drivers go. These driver files are usually installed on the system disk, which is the C drive of the computer. The specific location is in the RAZE folder under programfiles. In which folder is the Razer mouse driver located? A: In the RAZE folder under programfiles on the system C drive. Generally, the driver will be installed on the C drive, just find it according to the location. Introduction to Razer mouse driver installation method 1. After downloading the file from the official website, double-click to run the downloaded EXE file. 2. Wait for the software to load. 3. Here you can choose which driver you want to install. 4. After selecting, click "Install" in the lower right corner.

According to news from this site on August 12, VGN launched the co-branded "Elden Ring" keyboard and mouse series on August 6, including keyboards, mice and mouse pads, designed with a customized theme of Lani/Faded One. The current series of products It has been put on JD.com, priced from 99 yuan. The co-branded new product information attached to this site is as follows: VGN丨Elden Law Ring S99PRO Keyboard This keyboard uses a pure aluminum alloy shell, supplemented by a five-layer silencer structure, uses a GASKET leaf spring structure, has a single-key slotted PCB, and the original height PBT material Keycaps, aluminum alloy personalized backplane; supports three-mode connection and SMARTSPEEDX low-latency technology; connected to VHUB, it can manage multiple devices in one stop, starting at 549 yuan. VGN丨Elden French Ring F1PROMAX wireless mouse the mouse

This article explores issues that can arise when the mouse is unable to select or highlight text in Microsoft Word, and how to resolve them. Why can't I select text in Microsoft Word? The inability to select text in MSWord may be affected by a variety of reasons, such as permission restrictions, document protection, mouse driver issues, or file corruption. Solutions to these problems are provided below. Fix Microsoft Word cannot select or highlight text using mouse If Microsoft Word cannot select or highlight text using mouse, follow the solutions mentioned below: Make sure your left mouse button is working Check if you are eligible to change the file Update the driver of your mouse

CPI is also called countperinch. The CPI in the mouse is the sensitivity of the mouse. When using it, the higher the CPI number, the more sensitive the mouse is. Now in this article, the editor brings you an introduction to the function of the mouse CPI button. What does cpi mean? The meaning of x and y axis. The left button becomes the right button. The scroll wheel fails up and down. How to adjust the mouse and restore the mouse? What does cpi mean? Answer: The number of coordinate points fed back per inch during dynamic movement is the sensitivity of the mouse. Button function introduction: 1. Adjust the mouse movement speed button; 2. Adjust the mouse sensitivity by pressing the cpi key; 3. Dynamic indicators to measure mouse sensitivity; 4. The CPI can be freely adjusted between 500/1000CPI;

According to news from this website on March 22, Delux launched the M900Pro wireless gaming mouse with a right-handed ergonomic shape. The first pre-sale price starts at 199 yuan. Colorful M900Pro is designed with right-handed ergonomics and is built for users with medium to large hands. It weighs 63g and is sprayed with a matte UV coating. The mouse uses the PAW3395 sensor, the original Nano receiver supports 8000Hz wireless rate of return, is equipped with Huannuo blue shell pink dot micro-movement and comes standard with an RGB charging base and anti-slip stickers. In addition, the mouse also supports functions such as LOD adjustment, full-key customization, custom ripple control, and straight line correction. It is equipped with PTFE foot pads, 1.6m paracord cord, and a built-in receiver storage compartment. This site summarizes the specific parameters of this mouse as follows: Color: black, white, red
