Home > Web Front-end > JS Tutorial > body text

The phenomenon that offsetHeight is 0 in OnLoad_javascript skills

WBOY
Release: 2016-05-16 17:28:10
Original
1407 people have browsed it

When using IE, especially in the current div css method, the height of the div is often not defined. This is because when you need to obtain the height of the div after adding the div content, you often need to use offsetHeight.

In use, sometimes you will encounter the phenomenon that offsetHeight is obtained as 0, but if you use various JS debugging tools to debug, you can see the value in the object (it is worthless if you point it directly to offsetHeight , but if the object view has a value, the object has been refreshed by pressing Enter in the debugger, so it has a value)

For example, the following fragment

Copy code The code is as follows:











If you get the height of divcj, then onload What is obtained is 0. Because there is a float layout under divcj.
If the div is simple, you can use a hidden layer, such as divcj2 here. After removing the float, the height obtained will be the same as divcj.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template