This article describes the method of setting the body height to the browser height in JavaScript. Share it for your reference. The specific implementation method is as follows:
To achieve a percentage of the div node height, its parent node must have a certain height. Therefore, if a child node under the body node wants to determine the height using percentage, it must give the body a height.
Copy the code as follows:<script>
setTimeout(function(){
document.getElementsByTagName('body')[0].style.height = window.innerHeight+'px';
},20);
</script>
I hope this article will be helpful to everyone's JavaScript programming.