效果A:浏览器跳转以及判断来路客户信息

window.parent控制父对象跳转

判断手机型号

 private string PhoneType(string phonetype)
        {
            string startRule = ";([^(;)]*)/";
            Regex typeRule = new Regex(startRule);

            MatchCollection types = typeRule.Matches(phonetype);
            foreach (Match type in types)
            {
                if (type.Value.Contains("Build"))
                {
                    string result = type.Value.ToString().Substring(2, type.Value.ToString().IndexOf("/") - type.Value.ToString().IndexOf(";") - 2);
                    return result;
                }
            }
            if (phonetype.Contains("iPhone"))
            {
                int startIn = phonetype.IndexOf(";");
                phonetype = phonetype.Substring(startIn, 29);
                string iphoneRule = @"(d)_(d)_(d)";
                Regex iphoneType = new Regex(iphoneRule);
                if (iphoneType.IsMatch(phonetype))
                {
                    string result = iphoneType.Match(phonetype).ToString().Replace("_", "");
                    if (result == "511")
                    {
                        return "iphone4";
                    }
                    else
                    {
                        return "iphone5";
                    }
                }
            }
            return null;
        }

百度关键词

 /// <summary>
        /// 判断百度搜索来源
        /// </summary>
        /// <param name="referrer"></param>
        private string PushOrigInfo(string referrer)
        {
            if (referrer.Contains("baidu"))
            {
                string wdRule = "wd([^&]*)&";
                Regex regwd = new Regex(wdRule);
                System.Text.RegularExpressions.Match wdMath = regwd.Match(referrer);
                if (string.IsNullOrEmpty(wdMath.Value))
                {
                    wdRule = "bs([^&]*)&";
                    wdMath = regwd.Match(referrer);
                }

                string pnRule = "pn([^&]*)&";
                Regex regpn = new Regex(pnRule);
                System.Text.RegularExpressions.Match pnMath = regpn.Match(referrer);
                return wdMath.Value + ":" + pnMath.Value;
            }
            else
            {
                return null;
            }
        }

前端方式

 //获取搜索近来时的关键词
    var sosuo = aa.split(".")[1];
    var rep = null;
    var str = null;
    var keyword = null;
    switch (sosuo) {
        case "baidu":
            rep = /wd=.*&/i;
            str = aa.match(rep);
            keyword = str.toString().split("=")[1].split("&")[0];
            // return decodeURIComponent(keyword);
            
            break;
        case "google":
            rep = /wd=.*&/i;
            str = aa.match(rep);
            keyword = str.toString().split("=")[1].split("&")[0];
            
            break;
        case "sogou":
            rep = /wd=.*&/i;
            str = aa.match(rep);
            keyword = str.toString().split("=")[1].split("&")[0];
            
            break;
        default:
            return aa;
            break;
    }
View Code
原文地址:https://www.cnblogs.com/wanglao/p/3540808.html