Home >Web Front-end >JS Tutorial >How to get body.clientHeight after doctype_javascript skills

How to get body.clientHeight after doctype_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:11:141298browse

In ie6, problems will occur when executing many js scripts. Generally, incorrect values ​​will be returned when obtaining clientWidth, clientHeight, offsetWidth, offsetHeight, scrollWidth, scrollHeight, scrollTop, and scrollLeft.

Because after adding doctype, these document.body attributes have been reassigned to document.documentElement in ie6.

For example: the original document.body.clientHeight should be changed to document.documentElement.scrollTop

In order to adapt, you can change the following code:



((document.documentElement.clientHeight==0)?document.body.clientHeight:document.documentElement.clientHeight)


Using such code can be adaptive.

Statement:
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