1.请大家测试以下code
<script type="text/javascript">
var window_height=400;
var window_width=500;
window.resizeTo(window_height,window_width);
var heigth=window.screen.availHeight;
var width=window.screen.availWidth;
alert('hegth='+heigth+',width='+width);
</script>2.问题:我显示器的分辨率设置是1280*1024,为什么hegth=994,width=1280?
<script type="text/javascript">
var window_height=400;
var window_width=500;
window.resizeTo(window_height,window_width);
var heigth=window.screen.availHeight;
var width=window.screen.availWidth;
alert('hegth='+heigth+',width='+width);
</script>2.问题:我显示器的分辨率设置是1280*1024,为什么hegth=994,width=1280?
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<style type="text/css">
div{font-family:verdana; font-size:12px; padding:2px; margin:5px; border:1px solid red; height:30px;}
</style>
<script type="text/javascript">
function selectScreen(){
var w,h;
srn_w=screen.width;
srn_h=screen.height;
if(srn_w == 1024 && srn_h == 768){
alert("Screen 宽 : " + srn_w+"\nScreen 高 : "+srn_h+"\n显示比例模型 4 : 3");
//window.location = a.htm; //go and display a page here
}else if(srn_h == 768 && srn_w != 1024 ){
alert("Screen 宽 : " + srn_w+"\nScreen 高 : "+srn_h+"\n显示比例模型不是 4 : 3(可能是宽屏16:9)");
//window.location = b.htm; //go and display a page here
}else if(srn_w == 800 && srn_h == 600){
alert("Screen 宽 : " + srn_w+"\nScreen 高 : "+srn_h+"\n显示比例模型 4 : 3");
//window.location = c.htm; //go and display a page here
}else if(srn_h == 600 && srn_w != 800 ){
alert("Screen 宽 : " + srn_w+"\nScreen 高 : "+srn_h+"\n显示比例模型不是 4 : 3(可能是宽屏16:9)");
//window.location = d.htm; //go and display a page here
}else{
alert("other\n Screen 宽 : " + srn_w+"\nScreen 高 : "+srn_h+"\n显示比例模型不清楚");
//window.location = e.htm; //go and display a page here
}
}
selectScreen();
</script>
<body>
<br>
<br>
判断浏览起分辨率显示相应的页面...
</body>
</html>
screen.height;
同理availHeight height