js限制网页只在微信浏览器中打开js代码:
$(function(){ //判断页面是否是在微信浏览器打开 //对浏览器的UserAgent进行正则匹配,不含有微信独有标识的则为其他浏览器 var useragent = navigator.userAgent; if (useragent.match(/MicroMessenger/i) != 'MicroMessenger') { window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=888";//若不是微信浏览器,跳转到温馨error页面 } })
上一篇:页面仅限微信端访问JS代码