Home >Web Front-end >JS Tutorial >JavaScript method to set body height to browser height_javascript skills

JavaScript method to set body height to browser height_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:15:071510browse

The example in this article describes how to set the body height to the browser height using JavaScript. Share it with everyone for your reference. The specific implementation method is as follows:

For the height of a div node to be implemented as a percentage, its parent node must have a certain height. Therefore, if the child node under the body node wants to use a percentage to determine the height, it must give a height to the body.

Copy code The code is as follows:
<script> <br> ​ ​ ​ setTimeout(function(){  <br>                   document.getElementsByTagName('body')[0].style.height = window.innerHeight 'px'; <br>          },20);                                        </script>
I hope this article will be helpful to everyone’s JavaScript programming design.

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