网页自动适应分辨率 寻找自动适应分辨率的网页脚本 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 # IE:document.body.offsetWidth和document.body.offsetHeight。注意:此时页面一定要有body标签。 # FF:window.innerWidth和window.innerHegiht,以及document.documentElement.clientWidth和document.documentElement.clientHeight。 # 通用:document.body.clientWidth和document.body.clientHeight。 orscreenLeftscreenTop JS判断显示器不同的分辨率显示不同的页面<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""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> 针对具体的网页,绝不是仅依靠JS就可以的,还要注意CSS的写法(除非你有工夫象上面有位朋友提供的那样,针对每种分辨率分别去设计一个相应的页面).CSS写好了,不需要JS也可以适应不同分辨率.具体的可以找下DIV布局参考文章. 这个问题比较深奥了。一般通过css加div能解决页面大小适应性问题,以我个人不深的经验,使用position:absolute|relative,top,left,right,bottom.....确定页面整体框架,然后内部用百分比。当然还要有很多设计技巧,我也在不断探索中... 比较通用的就是div+css布局了!宽度按百分比来布! 这个思想我顶,我现在也强烈建议他们用DIV+CSS JS判断显示器不同的分辨率显示不同的页面HTML code<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/ht…… jquery给textarea赋值怎么不好用呢? 求助javascript代码的问题 jquery的问题 可否不把inline inline-block元素变成block元素而直接对其float啊 怎样替换两个div之间的内容? 页面自动提交代码!! 请高人帮助解决一个js正则表达式的问题 100---分关于表格的问题. 高分寻求解决办法!!急 JS中的 document.getElementById导致onchange整个函数不执行 求助:如何通过js切换图像? 请问用js怎样实现碰壁反弹效果?有示例代码吗?谢谢
# FF:window.innerWidth和window.innerHegiht,以及document.documentElement.clientWidth和document.documentElement.clientHeight。
# 通用:document.body.clientWidth和document.body.clientHeight。 or
screenLeft
screenTop
"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>
具体的可以找下DIV布局参考文章.
当然还要有很多设计技巧,我也在不断探索中...
JS判断显示器不同的分辨率显示不同的页面
HTML code<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/ht……