画面表示可能領域を取ります

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)。

 

おすすめ

転載: www.cnblogs.com/zhangzhengyang/p/11210848.html