<! Doctype html> <html> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <title> 每天一个 Javascript 实例-获取元素当前高度 </title> <style> #date {width: 90%; 25%; window.onload = function () {var height = getheight (); console.log (высота); } function getheight () {var height = 0; var div = document.getElementbyId ("date"). getBoundingClientRect (); if (div.height) {height = div.height; } else {height = div.bottom - div.top; } return Height; } </script> </head> <body> <div> <div id = "date"> </div> </div> </body> </html>