• 效果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
  • 相关阅读:
    SQL时间戳的使用
    Java中利用MessageFormat对象实现类似C# string.Format方法格式化
    XML中PCDATA与CDATA的区别
    树行控件TreeView 在WinForm下 怎么实现重命名功能
    PHP+MySQL存储数据出现中文乱码的问题
    C#创建一个Windows Service
    SQL2008配置管理工具服务显示远程过程调用失败
    C#如何以管理员身份运行程序
    在APACHE服务器上的访问方式上去除index.php
    开发winform程序,在拖拽控件大小时,VS会卡死
  • 原文地址:https://www.cnblogs.com/wanglao/p/3540808.html
Copyright © 2020-2023  润新知