开发者

Find out if HTC phone enters a mobile app

I know that this code will redirect for blackberries;

if ((/blackberry/i.test(navigator.userAgent))) {
        //Send to mobile page (Blackberries)
        window.location = ("../Default.aspx");
 } 

But what would I use to replace blackberry for HTC phones?

I looked here but there seems to be different ones for just about every phone. Is there a single call that I could use?

Edit A C# way to detect would work too. Something along the lines of this:

if (Request.Headers["User-Agent"] != null && (Request.Browser["IsMobileDevice"] == "true"){
                if(Request.Browser ["BlackBerry"] == "true")
                {
                    if(int.Parse(Request.Browser.Version) < 4.5)
                    {
                       //This is how you get blackberry version right?
                    }

                }
                else if开发者_C百科(Request.UserAgent.ToUpper().Contains("HTC"))
                {

                }
            }


To find if a phone is an HTC server side do this:

if(Request.UserAgent.ToUpper().Contains("HTC")){
   //Code
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜