<script type="text/javascript"> 
window.onload = function(){ 
if(!is_weixn()){ 
//var p = document.getElementsByTagName('p'); 
//p[0].innerHTML = '请用微信访问!';
document.writeln("请用微信访问!");
   return false;
function is_weixn(){
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i)=="micromessenger") {
        return true;
    } else {
        return false;
    }
</script> 


不过js的判断还是可以看到源码  用php比较靠谱
$user_agent = $_SERVER['HTTP_USER_AGENT'];
        if (strpos($user_agent, 'MicroMessenger') === false) {
            echo "非微信浏览器禁止浏览";exit();
        } else {
       $this->display("./Tpl/Loupan/Baoming/xiaogan/clsqyx/index.html");
        }

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

et_highlighter