- JavaScript屏幕对象:
描述屏幕的显示及颜色属性。
- JavaScript屏幕对象的属性:
格式: screen.属性
availHeight |
屏幕区域的可用高度 |
availWidth |
屏幕区域的可用宽度 |
colorDepth |
颜色深度 256/8 16/16 32M/32 |
height |
屏幕区域的实际高度 |
width |
屏幕区域的实际宽度 |
例1:
<Script>
with (document) {
write ("您的屏幕显示设定值如下:<P>");
write ("屏幕的实际高度为", screen.availHeight,
"<BR>");
write ("屏幕的实际宽度为", screen.availWidth,
"<BR>");
write ("屏幕的色盘深度为", screen.colorDepth,
"<BR>");
write ("屏幕区域的高度为", screen.height,
"<BR>");
write ("屏幕区域的宽度为", screen.width);
}
</Script>
例2:
<Script>
if ( screen.width < 800 || screen.colorDepth < 8 ){
var msg = "本网站最佳浏览模式为 800 * 600 *
256";
alert(msg);
}
</Script>
|