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
}
精彩评论