JSは、ブラウザのウィンドウのサイズを取得します

抜粋します。https://blog.csdn.net/qq_27628085/article/details/81947478

 

共通:

JSは、ブラウザのウィンドウのサイズを取得します。

  1.  
     
  2.  
    //ウィンドウの幅を取得します。
  3.  
    (もしwindow.innerWidth)
  4.  
    winWidth = window.innerWidth。
  5.  
    それ以外の場合((document.body)&&(document.body.clientWidth))
  6.  
    winWidth = document.body.clientWidth。
  7.  
    //ウィンドウの高さを取得します。
  8.  
    (もしwindow.innerHeight)
  9.  
    winHeight = window.innerHeight。
  10.  
    それ以外の場合((document.body)&&(document.body.clientHeight))
  11.  
    winHeight = document.body.clientHeight。
  12.  
    //ウィンドウサイズを取得するには、綿密な内部文書を通じて体を検出
  13.  
    (場合はdocument.firstChild && document.documentElement.clientHeight && document.documentElement.clientWidth)
  14.  
    {
  15.  
    winHeight = document.documentElement.clientHeight。
  16.  
    winWidth = document.documentElement.clientWidth。
  17.  
    }

詳細:

 

ブラウザのウィンドウサイズの様々な可視のアクセス: 

  1.  
     
  2.  
    機能はgetinfo(
  3.  
    {
  4.  
    VAR S = "";
  5.  
    = S 「ページ広い可視領域:」document.body.clientWidth。
  6.  
    = S 「高い可視領域のページ:」document.body.clientHeight。
  7.  
    = S 「ページ広い可視領域:」document.body.offsetWidth 「(ワイド端とスクロールバーを含みます)」;
  8.  
    = S 「高い可視領域のページ:」document.body.offsetHeight 「(エッジ幅を含みます)」。
  9.  
    = S 「全幅ウェブテキスト:」document.body.scrollWidth。
  10.  
    = S 「ページGAOの身体:」document.body.scrollHeight。
  11.  
    = S "ハイにロールウェブ(FF):" document.body.scrollTop。
  12.  
    = S "ハイボリュームページである(IE):" document.documentElement.scrollTop。
  13.  
    = S 「ウェブは左に巻かれている:」document.body.scrollLeft。
  14.  
    = S 「ページ本体部分に:」window.screenTop。
  15.  
    = S 「ページの左ボディの部分:」window.screenLeft。
  16.  
    = S 「高い画面解像度:」window.screen.height。
  17.  
    = S 「ワイドスクリーン解像度:」window.screen.width。
  18.  
    = S 「高ワークスペース画面が用意されています」window.screen.availHeight。
  19.  
    = S 「幅ワークスペース画面が用意されています」window.screen.availWidth。
  20.  
     
  21.  
    = S 「あなたの画面の設定には」window.screen.colorDepth 「ビット色」。
  22.  
    = S 「あなたの画面設定の」window.screen.deviceXDPI 「ピクセル/インチ」。
  23.  
    //警告(秒)。
  24.  
    }
  25.  
    情報を取得();

 

IE、FireFoxの、オペラで使用することができ 
document.body.clientWidth 
document.body.clientHeight 
あなたは、非常に便利な、非常に単純な取得することができます。 
同社のプロジェクト: 
Operaはまだ使用しています 
document.body.clientWidth 
document.body.clientHeight 
が、IEとFirefoxの使用 
document.documentElement.clientWidth 
document.documentElement.clientHeightは、 
プレイああでW3Cの標準であることが判明し 
、<!DOCTYPE HTML PUBLIC「 - ! // W3C // DTD XHTML 1.0過渡//  EN「」http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd「>
あなたはこのラインマークにIEでページ上の単語を追加する場合: 
document.body.clientWidth ==>オブジェクトのボディの幅 
document.body.clientHeight ==>オブジェクトの身長 
document.documentElement.clientWidth ==>可視領域幅 
document.documentElement.clientHeight ==>高度に可視領域 
Firefoxの: 
document.body.clientWidth ==>オブジェクトのボディの幅 
document.body.clientHeight ==>オブジェクトの身長 
document.documentElement.clientWidth ==>可視領域幅 
document.documentElement.clientHeight ==>視認性の高い領域 
? 
オペラ: 
ドキュメント.body.clientWidth ==>可視領域幅 
document.body.clientHeight ==>高度に可視領域 
document.documentElement.clientWidth ==>ページオブジェクトの幅(すなわち、幅オブジェクトプラスBODYマージン幅の) 
document.documentElement.clientHeight ==>ページオブジェクトの高さ(すなわち、高BODY余裕をもって結合オブジェクトの高さ) 
W3C標準は、定義されていない場合 
、IE: 
document.documentElement.clientWidth ==> 0 
document.documentElement.clientHeight ==> 0 
Firefoxなど。 
document.documentElement.clientWidth ==>ページオブジェクトの幅(すなわち、幅オブジェクトプラスBODYマージン幅の)document.documentElement.clientHeight ==>ページオブジェクトの高さ(すなわち、高BODYマージンで結合オブジェクトの高さ) 
Operaがある: 
document.documentElement.clientWidth ==>ページオブジェクトの幅(すなわち、幅オブジェクトプラスBODYマージン幅の)document.documentElement.clientHeight ==>ページオブジェクトの高さ(すなわち、高マージン体と結合オブジェクトの高さ)
 

おすすめ

転載: www.cnblogs.com/qq376142178/p/11850418.html