WEB上自动获得分辨率大小

13abyKnight 2010-06-02 02:07:12
需求
1.根据不同的液晶宽度或者高度能自动调整出同样的布局。

2.如果,使用JS完成的话如果换操作系统是否影响呢?

3.是否可以把数据展示的布局能根据当前显示器大小调整相应的布局呢。



谢谢,大侠们。

...全文
96 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangjiang87 2010-06-02
  • 打赏
  • 举报
回复
学习中
13abyKnight 2010-06-02
  • 打赏
  • 举报
回复
<SCRIPT LANGUAGE="JavaScript">
<!--
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
var IE1024="";
var IE800="";
var IE1152="";
var IEother="";
ScreenWidth(IE1024,IE800,IE1152,IEother)
}
else{
if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
var Firefox1024="";
var Firefox800="";
var Firefox1152="";
var Firefoxother="";
ScreenWidth(Firefox1024,Firefox800,Firefox1152,Firefoxother)
}
else{
var Other1024="";
var Other800="";
var Other1152="";
var Otherother="";
ScreenWidth(Other1024,Other800,Other1152,Otherother)
}
}
function ScreenWidth(CSS1,CSS2,CSS3,CSS4){
if ((screen.width == 1024) && (screen.height == 768)){
setActiveStyleSheet(CSS1);
}else{
if ((screen.width == 800) && (screen.height == 600)){
setActiveStyleSheet(CSS2);
}else{
if ((screen.width == 1152) && (screen.height == 864)){
setActiveStyleSheet(CSS3);
}else{
setActiveStyleSheet(CSS4);
}}}
}
function setActiveStyleSheet(title){
document.getElementsByTagName("link")[0].href="style/"+title;
}
//-->
</SCRIPT>

这也是根据不同浏览器以及显示器大小得到分辨率
13abyKnight 2010-06-02
  • 打赏
  • 举报
回复
目前,我是没有找到这样的方法啊。如果,针对于WIN那么换OS不就是挂了嘛
危险的大猫 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 daocha 的回复:]
use
document.body.clientHeight
document.body.clientWidth
to get the actual size in different resolutions
[/Quote]

thank..
daocha 2010-06-02
  • 打赏
  • 举报
回复
use
document.body.clientHeight
document.body.clientWidth
to get the actual size in different resolutions
izard999 2010-06-02
  • 打赏
  • 举报
回复
宽度和高度用百分比定义下?
xinlan1022 2010-06-02
  • 打赏
  • 举报
回复
不会。。。学习。。。

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧