如何设置网页只能在微信浏览器中打开

Author: 陌小雨Date: 2017-11-07View: 94

今天在微信玩了下漂流瓶,发现有人利用这个来制作那种不可描述的视频需要打赏后才能观看,准备用电脑访问下,于是发现了这个方法,设置后就只能允许用户在微信浏览器中打开:

            var ua = navigator.userAgent.toLowerCase();
            var isWeixin = ua.indexOf('micromessenger') != -1;
            var isAndroid = ua.indexOf('android') != -1;
            var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
            if (!isWeixin) {
                document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">';
                document.body.innerHTML = '</p>
<div class="weui_msg">
<div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div>
<div class="weui_text_area">
<h4 class="weui_msg_title">请在微信客户端打开链接</h4>
</div>
</div>
<p>';
            }