admin 管理员组

文章数量: 1184232

经常需要做一些表单验证和投票,为了防止恶意刷票,使页面不能在微信以外的浏览器中打开
这是js的代码:

<script type="text/javascript">
    function is_weixin(){
        var ua = navigator.userAgent.toLowerCase(); //判断浏览器的类型
        if(ua.match(/MicroMessenger/i)=="micromessenger") {
            return true;
        } else {
            return false;
        }
    }

    if (!is_weixin()) { // 如果不是微信内置浏览器,就动态跳转到以下页面
        window.location.href = 'https://open.weixin.qq/connect/oauth2/authorize?appid=wxdf3f22ebfe96b912&redirect_uri=xxx&response_type=code&scope=snsapi_base&state=hyxt#wechat_redirect';
    }
</script>

本文标签: 只在 器中 网页 JS