1つの クライアント:関数(){ 2 であれば(!window.innerWidth == NULL){ // 最新的浏览器 3 リターン{ 4 "幅" :window.innerWidth、 5 "高さ" :window.innerHeight 6 } 7 } さもなければ もし(document.compatMode === 'CSS1Compat'){ // W3C 8 リターン{ 9 "幅" :document.documentElement.clientWidth、 10 "高さ" :document.documentElement.clientHeight 11 } 12 } 13 リターン{ 14 "幅" :document.body.clientWidth、 15 "高さ" :document.body.clientHeight 16 } 17 }
1 にconsole.log(window.innerWidth、window.innerHeight)。 2 にconsole.log(document.documentElement.clientWidth、document.documentElement.clientHeight)。 3にconsole.log(document.body.clientWidth、document.body.clientHeight)。