设计、网站、推广
始于2004年
当前位置:首页 > 网站制作

ASP获取客户端屏幕分辨率、ASP获得用户分辨率

发表日期:2015-6-29 作者来源:派谷网络 浏览次数:

实现方法:
在访问网页的时候使用js获得浏览器的分辨率然后转向本网页并把分辨率传出去,然后接收分辨率并把它存储在session中,最后再转到之前的网页
代码:
<%
'若已经自动转向执行此条件语句
if Bint(trim(request("sw"))) > 0 then
   session("MyScreenWidth")=Bint(trim(request("sw")))
   session("MyScreenHeight") = Bint(trim(request("sh")))
   response.Redirect(session("FrontUrl"))
end if
%>
<%
'第一次访问网页
if Bint(session("MyScreenWidth"))=0 then
if Bint(trim(request("sw"))) = 0 then
   session("FrontUrl") = GetUrl()
end if
response.Write("<scr"&"ipt>")
if Instr(GetUrl(),"?") > 0 then
   response.Write("window.location='"&GetUrl()&"&sw='+screen.width+'&sh='+screen.height;")
else
   response.Write("window.location='"&GetUrl()&"?sw='+screen.width+'&sh='+screen.height;")
end if
response.Write("</scr"&"ipt>")
end if
%>

<%="你的分辨率是:"&session("MyScreenWidth")&"*"&session("MyScreenHeight")%>

<%
'下面是几个函数
Function Bint(str)
If IsNumeric(str) then
   Bint = Clng(str)
Elseif IsEmpty(str) then
   Bint = 0
Elseif IsNull(str) then
   Bint = 0
Else
   Bint = 0
End if
End function
Function GetUrl()
sUrl = Request.ServerVariables("URL")
sQueryString = ""
For Each x In Request.QueryString
sQueryString = sQueryString & "&" & x & "=" & Server.URLEncode(Request(x))
Next
if len(sQueryString)>0 then
sQueryString = right(sQueryString,len(sQueryString)-1)
else
sQueryString = ""
end if
if len(sQueryString)>0 then
GetUrl = sUrl & "?" & sQueryString
else
GetUrl = sUrl
end if
End function
%>

本文章系本站编辑转载,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本站联系,我们将在第一时间删除内容!

相关网站设计案例

相关推荐新闻
网站建设解决方案