用js限制网页只能在微信内置浏览器或支付宝内置浏览器中打开

    function is_weixinOrAli(){
            var ua = navigator.userAgent.toLowerCase(); //判断浏览器的类型
            if (ua.match(/MicroMessenger/i) != "micromessenger" && ua.match(/Aplipay/i) != "aplipay") {
                // 如果不是微信内置浏览器,或支付宝内置浏览器,就动态跳转到以下页面
                window.location.href = "http:www.baidu.com";
                //window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxdf3f22ebfe96b912&redirect_uri=xxx&response_type=code&scope=snsapi_base&state=hyxt#wechat_redirect';
            } 
        }

 

posted @ 2019-01-02 09:34  Iven_雨之恋  阅读(1820)  评论(1编辑  收藏  举报