请教:如何知道浏览器的分辨率。

wangfang 2000-07-26 04:58:00
在asp中,如何用代码实现分辨率的问题。另外,我想在网页上做一个FAQ,请问在哪个站点
可以下载,或哪位大虾有源代码提供给我也行,我的e-mail是:fangzhongdong@163.net
.谢了!
...全文
765 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lczddd 2000-07-27
  • 打赏
  • 举报
回复
<%=Request.ServerVariables ("http_ua_pixels")%><P>
yiwei 2000-07-27
  • 打赏
  • 举报
回复
不过,我想,是不是可以在客户端的脚本里把分辨率属性写入到cookies里,然后在ASP页面里读取cookie。仅仅是设想,没有实验过。
华南虎哥 2000-07-26
  • 打赏
  • 举报
回复
yiwei说得对,上面这段程序在IE5以及IE5以上不能使用。
使用window.screen.width及window.screen.height显示的正常显示器的分辩率
使用window.screen.availwidth及window.screen.availheight显示的则是排除了任务栏工具条后的分辩率,比如你任务栏放上边或下边就是availheight小,放左边或右边就是availwidth小。
不过我还是推荐使用window.screen.width/height为好,大家易明白
yiwei 2000-07-26
  • 打赏
  • 举报
回复
这个asp程序可显示IE.NC客户端的屏幕分辨率

关键词:ASP

要求使用最新的browscap.ini,不然造成IE5,NC46等新的浏览器无法正确运行.

<HTML>
<head>
<TITLE>detectres.asp</TITLE>
</head>

<%
Set bc = Server.CreateObject("MSWC.BrowserType")
brname=bc.browser
brver=bc.version
%>
<% if brname="IE" and cint(brver)>=4 then %>
<body bgcolor=white onload="doit()">
<script language=vbscript>
<!--
sub doit()
document.write "Your screen width is : " & screen.width & " pixels<br>"
document.write "Your screen height is : " & screen.height & " pixels<br>"
document.write "Your clientWidth is : " & document.body.clientWidth
document.write " pixels<br>"
document.write "Your clientHeight is : " & document.body.clientHeight
document.write " pixels<br>"
' add the rest of the of the page's
' IE4 html code here...using document.write like :
document.write "<br><A HREF='blank.htm'>blank link</A>"
end sub
-->
</script>
'any regular html code you put here
'will disappear after the document.writes
</body>
</html>
<% else %>

<body bgcolor=white>
<% response.write "You're using " & brname & ", version # " & cint(brver) & " with " %>

<% if brname="IE" and cint(brver)=3 then
pixels=Request.ServerVariables("HTTP_UA_PIXELS")
color=Request.ServerVariables("HTTP_UA_COLOR")
response.write "Pixels=" & pixels & ", colors=" & colors
%>
<p>

' add the rest of the page's IE3 html code here...

</body>
</html>
<% end if %>

<% if brname="Netscape" and (cint(brver) > 1) then %>
<body bgcolor=white>
<Script Language="JavaScript">
<!--
if(navigator.javaEnabled())
{
var tools=java.awt.Toolkit.getDefaultToolkit();
var size=tools.getScreenSize();
w=size.width;
h=size.height;
}
document.write("Screen size : " + w + " x " + h + " pixels.");
//-->
</script>
<% end if %>
<p>
' add other Netscape html code here...like :
<br>
<A HREF="blank.htm">blank link</A>
</body>
</html>
<% end if %>

yiwei 2000-07-26
  • 打赏
  • 举报
回复
不正确,从客户端脚本获得分辨率是没有意义的。目前似乎没有什么好办法可以获得它。但是可以使用servervariables数据集合:request.servervariables("http_ua_pixels"),它在某些版本的IE上有效。

wangfang 2000-07-26
  • 打赏
  • 举报
回复
回答正确,给分吧
huntout 2000-07-26
  • 打赏
  • 举报
回复
javascript:
window.screen.width
window.screen.height
huntout 2000-07-26
  • 打赏
  • 举报
回复
<script language=javascript>
alert(window.screen.availWidth);
alert(window.screen.availHeight);
</script>
Tyro 2000-07-26
  • 打赏
  • 举报
回复
Screen.height和Screen.width获得屏幕像素的高度和宽度

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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