实现方法:
在访问网页的时候使用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
%>
中国足彩网信息请查看IT技术专栏