<! Doctype html> <html> <éadf> <meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" /> <ititle> 每天一个 javascript 实例 - 获取元素当前高度 </ title> <style> #date {width: 90%; heurt: 25%; padding: 10px; background: redth;} window.onload = function () {var height = getHeight (); console.log (hauteur); } fonction getheight () {var height = 0; var div = document.getElementById ("Date"). GetBoundingClientRect (); if (div.height) {height = div.height; } else {height = div.bottom - div.top; } Hauteur de retour; } </ script> </ head> <body> <div> <div id = "Date"> </div> </div> </odbody> </html>