一念行者
一切有为法,皆梦幻泡影。如露亦如电,应作如是观。笑着面对,不去埋怨。悠然,随心,随性,随缘。注定让一生改变的,只在百年后,那一朵花开的时间。
<%@ Page Language="C#" AutoEventWireup="true" Inherits="Jiubang.Wap.Page" Debug="true" ContentType="text/html; charset=UTF-8" %>
<%@ Import Namespace="Jiubang.Wap"%>
<%@ Import Namespace="Jiubang.Sql"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="CustomerAD.CommonLibrary" %>
<% Response.ContentType = "text/html; charset=UTF-8"; %>

<script runat="server">
    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 = "<meta http-equiv=\"refresh\" content=\"1;url=tel:" + this.TelNum + "\">";
            this.htmlContent = "<a href=\"tel:" + this.TelNum + "\">" + this.TelNum + "</a>";
        }
        else 
        {
            //安卓
            this.RefleshContent = "<meta http-equiv=\"refresh\" content=\"1;url=wtai://wp/mc;" + this.TelNum + "\">";
            this.htmlContent = "<a href=\"wtai://wp/mc;" + this.TelNum + "\">" + this.TelNum + "</a>";
        }
    }

    private string TelNum = string.Empty;
    private string RefleshContent = string.Empty;
    private string htmlContent = string.Empty;
    
</script>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0"/>
    <%=this.RefleshContent %>
    <title>拨打电话</title>
</head>

<body>
如果您的浏览器不支持自动拨打,请点击下面的连接拨打:<%=this.htmlContent %>
<br />
<div style="line-height:180%;text-align:center;">
    <%=LinkHelper.GetATag("index.aspx","返回首页") %>
</div>
</body>
</html>
View Code

 附上其中Common.GetUAInfo的方法

        /// <summary>
        /// 获取用户UA信息
        /// </summary>
        /// <param name="MobSystem">操作系统,2为安卓,3为iphone,ipod等苹果系列</param>
        /// <param name="IsUC">是否UC</param>
        /// <param name="http_UA">UA参数</param>
        /// <param name="http_WapPro">用户配置信息</param>
        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

 

posted on 2013-05-21 10:46  一念行者  阅读(920)  评论(5编辑  收藏  举报