1 // 判断环境 2 // web-view下的页面内 3 var ua = navigator.userAgent.toLowerCase(); 4 if(ua.match(/MicroMessenger/i)=="micromessenger") {//从微信中打开 5 if (!window.WeixinJSBridge || !WeixinJSBridge.invoke) { 6 if(window.__wxjs_environment === 'miniprogram'){ // 当前为小程序 7 console.log("小程序2") 8 }else{ 9 console.log("微信") // 当前为微信 10 $(".footer").show(); 11 $("#h5").hide(); 12 $("#wx").show() 13 } 14 16 } 17 } else { 18 console.log("H5")// 手机浏览器 19 $(".footer").show(); 20 $("#h5").show(); 21 $("#wx").hide() 22 }
判断当前H5页面在小程序,微信,浏览器环境
猜你喜欢
转载自www.cnblogs.com/linsx/p/9255824.html
今日推荐
周排行