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>

  • 相关阅读:
    设计模式——单例模式
    设计模式——工厂模式在开发中的应用(简单计算器)
    设计模式——简单工厂模式—工厂方法模式—抽象工厂模式(比较)
    设计模式——抽象工厂模式
    设计模式——工厂方法模式
    设计模式——简单工厂
    Win7使用初体验
    上传文件夹
    java上传文件夹到oss
    java+上传一个文件夹
  • 原文地址:https://www.cnblogs.com/ishuanghe/p/5561127.html
Copyright © 2011-2022 走看看