检测客户端显示相应页面asp+js代码。

发表于:2007-06-30来源:作者:点击数: 标签:
% bigurl = bigscreen.htm smallurl = smallscreen.htm A = LCase(Request.ServerVariables(HTTP_USER_AGENT)) if instr(A,msie 5)0 or instr(A,msie 4)0 then % script language= Java Script var w = document.body.clientWidth; if (w=650) { window.locat
<%
    bigurl = "bigscreen.htm"
    smallurl = "smallscreen.htm"
    A = LCase(Request.ServerVariables("HTTP_USER_AGENT"))
    if instr(A,"msie 5")>0 or instr(A,"msie 4")>0 then
%>

        <script language="JavaScript">
        var w = document.body.clientWidth;
        if (w>=650)
        {
            window.location.href="<%=bigurl%>";
        }
        else
        {
            window.location.href="<%=smallurl%>";
        }
        </script>

<%
    elseif instr(A,"msie 3")>0 then

        smallurl = "smallscreen.htm"
        bigurl = "bigscreen.htm"
        a = request("http_ua_pixels")
        url = smallurl
        if instr(a,"x")>0 then
            a = split(a,"x")
            if clng(a(0)) >= 650 then
                url = bigurl
            end if
        end if
        response.redirect(url)

    elseif instr(A,"zilla/4")>0 Then
%>

        <script language="JavaScript">
        var w = document.body.clientWidth;
        if (w>=650)
        {
            window.location.href="<%=bigurl%>";
        }
        else
        {
            window.location.href="<%=smallurl%>";
        }
        </script>

<%
    elseif instr(A,"zilla/3")>0 then
%>

        <script language="javascript">
        var Sizer=java.awt.Toolkit.getDefaultToolkit();
        var ScrSize=Sizer.getScreenSize();
        var ScrW=ScrSize.width;
        if (ScrW>=650)
        {
            window.location.href="<%=bigurl%>";
        }
        else
        {
            window.location.href="<%=smallurl%>";
        }
        </script>

<%
    else
        respose.redirect(smallurl)
    end if
%>

原文转自:http://www.ltesting.net