protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.TelNum = "400-8877766";
int mobs=0;
bool isuc=false;
string http_ua=string.Empty;
string http_pro=string.Empty;
Common.GetUAInfo(ref mobs, ref isuc, ref http_ua, ref http_pro);
if (mobs == 3)
{
//iphone系列
this.RefleshContent = "";
this.htmlContent = "" + this.TelNum + "";
}
else
{
//安卓
this.RefleshContent = "";
this.htmlContent = "" + this.TelNum + "";
}
}
private string TelNum = string.Empty;
private string RefleshContent = string.Empty;
private string htmlContent = string.Empty;
拨打电话如果您的浏览器不支持自动拨打,请点击下面的连接拨打:
View Code
附上其中Common.GetUAInfo的方法
///
/// 获取用户UA信息
///
/// 操作系统,2为安卓,3为iphone,ipod等苹果系列
/// 是否UC
/// UA参数
/// 用户配置信息
public static void GetUAInfo(ref int MobSystem, ref bool IsUC,ref string http_UA,ref string http_WapPro)
{
int mobos = 0; //操作系统版本
int isuc = 0; //是否UC
string ALLUSERUA = ""; //用户UA
string ALLWAPPRO = ""; //用户配置信息
//获取UA
if (HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"] != null)
{
ALLUSERUA = HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"].ToString().Trim();
}
//获取配置信息
if (HttpContext.Current.Request.ServerVariables["HTTP_X_WAP_PROFILE"] != null)
{
ALLWAPPRO = "3G" + HttpContext.Current.Request.ServerVariables["HTTP_X_WAP_PROFILE"].ToString().Trim();
}
if (ALLUSERUA.IndexOf("UCWEB") > 0 || ALLWAPPRO.IndexOf("UCWEB") > 0 || ALLUSERUA.IndexOf("UCWEB") > 0 || ALLUSERUA.IndexOf(" UC ") > 0)
{
isuc = 1;
}
if (ALLUSERUA.IndexOf("QQBrowser") > 0 || ALLWAPPRO.IndexOf("QQBrowser") > 0 || ALLUSERUA.IndexOf("QQBrowser") > 0)
{
isuc = 1;
}
if (ALLUSERUA.IndexOf("Android") > 0 || ALLWAPPRO.IndexOf("Android") > 0 || ALLUSERUA.IndexOf("Ophone") > 0)
{
mobos = 2;
}
if (ALLUSERUA.IndexOf("UC") > 0 && ALLUSERUA.IndexOf("Linux") > 0)
{
mobos = 2;
}
if (ALLUSERUA.IndexOf("QQBrowser") > 0 && ALLUSERUA.IndexOf("Linux") > 0)
{
mobos = 2;
}
if (ALLUSERUA.IndexOf("iPhone") > 0 || ALLUSERUA.IndexOf("iPad") > 0 || ALLUSERUA.IndexOf("GT-I9000") > 0 || ALLUSERUA.IndexOf("IOS") > 0)
{
mobos = 3;
}
if (ALLUSERUA.IndexOf("UC") > 0 && ALLUSERUA.IndexOf("iOS") > 0)
{
mobos = 3;
}
if (ALLUSERUA.IndexOf("QQBrowser") > 0 && ALLUSERUA.IndexOf("iOS") > 0)
{
mobos = 3;
}
MobSystem = mobos;
IsUC = (isuc == 1);
http_UA = ALLUSERUA;
http_WapPro = ALLWAPPRO;
}
View Code
来源:https://www.cnblogs.com/huangguohua/archive/2013/05/21/3090292.html