zoukankan      html  css  js  c++  java
  • 判断是否是用微信打开、是否是用微信朋友圈打开

    ①判断是否是用微信打开

    <script>
            $(window).on("load",function(){
                function is_weixin() {
                    var ua = navigator.userAgent.toLowerCase();
                    if (ua.match(/MicroMessenger/i) == "micromessenger") {
                        return true;
                    } else {
                        return false;
                    }
                }
            })
        </script>

    ②判断是否是用微信朋友圈打开

    方法一:

    <script>

    $(window).on("load",function(){
                function isnot_weixin() {
                    var ua = navigator.userAgent.toLowerCase();
                    var wlocat=window.location;
                    var re = /timeline/;
                    if (!(ua.match(/MicroMessenger/i) == "micromessenger")||(re.test(wlocat)==false)) {
                        return true;
                    } else {
                        return false;
                    }
                }
            })

    </script>

    方法二:

    <script>  
    $(window).on("load",function(){
        function GetQueryString(name)
        {
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        function is_weixin() {
            var ua = navigator.userAgent.toLowerCase();
            var ga = GetQueryString("from");
            if (ua.match(/MicroMessenger/i) == "micromessenger" && ga.match(/timeline/i) == "timeline") {
                return true;
            } else {
                return false;
            }
        }
    })

    </script>

    ③判断如果不是用微信朋友圈打开的:

    <script>

    $(window).on("load",function(){
                function isnot_weixin() {
                    var ua = navigator.userAgent.toLowerCase();
                    var wlocat=window.location;
                    var re = /timeline/;
                    if (!(ua.match(/MicroMessenger/i) == "micromessenger")||(re.test(wlocat)==false)) {
                        return true;
                    } else {
                        return false;
                    }
                }
            })

    </script>

  • 相关阅读:
    4.内核编译和裁剪
    2.Linux技能要求
    3.字符驱动框架
    1.Linux命令
    4.类和抽象
    3.指针
    2.C++语言特性
    1.编译器
    计数排序——Counting Sort
    网关、网桥、路由器、集线器
  • 原文地址:https://www.cnblogs.com/ishuanghe/p/5561127.html
Copyright © 2011-2022 走看看