JavaScript ディスプレイのサイズを取得する
「width」プロパティと「height」プロパティは、スクリーン全体の幅と高さの値を返します。「availWidth」プロパティと「availHeight」プロパティは、スクリーン全体からWindowsのタスクバーのように表示できない部分を除いたスクリーンの幅と高さの値を、それぞれ返します。
JavaScript1.2で追加された、読み出し専用プロパティです。
- プロパティ:screen.width
- プロパティ:screen.height
- プロパティ:screen.availWidth
- プロパティ:screen.availHeight
document.write("スクリーンの幅(pixels):",screen.width);
document.write("<br>");
document.write("スクリーンの高さ(pixels):", screen.height);
document.write("<br>");
document.write("使用可能なスクリーンの幅(pixels):",screen.availWidth);
document.write("<br>");
document.write("使用可能なスクリーンの高さ(pixels):",screen.availHeight);
