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

80酷酷网    80kuku.com

  asp+|js|客户端|显示|页面<%
    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
%>

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: