Blog Stats
  • Posts - 150
  • Articles - 0
  • Comments - 36
  • Trackbacks - 0

 

Is Blackberry?

I've just modified my auto detection web page to work with windows mobile,  iPhone/iPod and now Blackberry

This simple web-page will redirect traffic to different web pages for any of these devices.

Paste this into an asp.net web page (i.e default.aspx)

 

 

<%@ Page Language="C#" Trace="false" %>

<SCRIPT LANGUAGE="C#" RUNAT=SERVER>

    protected void Page_Load(Object sender, EventArgs e)
    {
        System.Web.Mobile.MobileCapabilities cur = (System.Web.Mobile.MobileCapabilities) Request.Browser;

        // this block of code is to detect if users are running Pocket PC 2003
        bool isce=false;
        bool isiphone=false;
            bool isipod=false;
        bool isblackberry=false;

        try    {
               isce = (Request.UserAgent.IndexOf("Windows CE")!=-1);
                   isiphone = (Request.UserAgent.IndexOf("iPhone;")!=-1);
                   isipod = (Request.UserAgent.IndexOf("iPod;")!=-1);
                   isblackberry = (Request.UserAgent.IndexOf("BlackBerry")!=-1);

        }
        catch
        {

        }
        if (isiphone||isipod)
        {
            Response.Redirect("/m");
            return;
        }

        if (isblackberry)
        {
            Response.Redirect("/blackberry");
            return;
        }

        if (cur.IsMobileDevice||isce)
        {               
            Response.Redirect("/mobile");
            return;
        }

        Response.Redirect("/jumpstart");

    }

</SCRIPT>


Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 
 

 

 

Copyright © Richard Jones