明辉站/网站教程/内容

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

网站教程2024-05-23 阅读
[摘要]<% bigurl = "bigscreen.htm" smallurl = "smallscreen.htm" A = LCase(Request.ServerVariables("HTTP_USER_AGENT&q...

<%
    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
%>

……

相关阅读