发布:2023/12/7 15:50:56作者:大数据 来源:大数据 浏览次数:536
有时需要在微信里打开H5业务应用系统,在其它浏览器打开提示:
具体实现代码如下:
1 2 3 4 5 |
var useragent = navigator.userAgent.toLowerCase(); var iswechat = useragent.indexOf('micromessenger') !== -1; if (!iswechat) { window.location.href = 'http://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90b252e89d5742e3' } |
或者如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" /> </head> <body> <script type="text/javascript"> 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 = '<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>'; } </script> </body> </html> |
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4