實(shí)現(xiàn)方法:
在訪問(wèn)網(wǎng)頁(yè)的時(shí)候使用js獲得瀏覽器的分辨率然后轉(zhuǎn)向本網(wǎng)頁(yè)并把分辨率傳出去,然后接收分辨率并把它存儲(chǔ)在session中,最后再轉(zhuǎn)到之前的網(wǎng)頁(yè)
代碼:
<%
'若已經(jīng)自動(dòng)轉(zhuǎn)向執(zhí)行此條件語(yǔ)句
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
%>
<%
'第一次訪問(wèn)網(wǎng)頁(yè)
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")%>
<%
'下面是幾個(gè)函數(shù)
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
%>
更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄