如何用ASP獲取客戶端屏幕分辨率,我們可以通過以下方式實現:
在訪問網頁的時候使用js獲得瀏覽器的分辨率然后轉向本網頁并把分辨率傳出去,然后接收分辨率并把它存儲在session中,最后再轉到之前的網頁
代碼:
<%
'若已經自動轉向執行此條件語句
if Bint(trim(request("sw"))) > 0 then
end if
%>
<%
'第一次訪問網頁
if Bint(session("MyScreenWidth"))=0 then
if Bint(trim(request("sw"))) = 0 then
end if
response.Write("<scr"&"ipt>")
if Instr(GetUrl(),"?") > 0 then
else
end if
response.Write("</scr"&"ipt>")
end if
%>
<%="你的分辨率是:"&session("MyScreenWidth")&"*"&session("MyScreenHeight")%>
<%
'下面是幾個函數
Function Bint(str)
If IsNumeric(str) then
Elseif IsEmpty(str) then
Elseif IsNull(str) then
Else
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
%>
新聞熱點
疑難解答