判断是否在微信浏览器打开
微信官方的写法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <! DOCTYPE html> < html > < head > < 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 > |
夏柔的写法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <! DOCTYPE html> < html > < head > < title >抱歉,出错了</ title > < meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"> < style > @font-face { font-family: 'iconfont'; /* Project id 3213278 */ src: url('//at.alicdn.com/t/font_3213278_flhy4e6wbjg.woff2?t=1646127490384') format('woff2'), url('//at.alicdn.com/t/font_3213278_flhy4e6wbjg.woff?t=1646127490384') format('woff'), url('//at.alicdn.com/t/font_3213278_flhy4e6wbjg.ttf?t=1646127490384') format('truetype'); } .iconfont { font-family: "iconfont"; font-size: 14px; font-style: normal; } </ style > </ head > < body > < script type="text/javascript"> var ua = navigator.userAgent.toLowerCase(); var isWeixin = ua.indexOf('micromessenger') != -1; var ua = navigator.userAgent; var ipad = ua.match(/(iPad).*OS\s([\d_]+)/), isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/), isAndroid = ua.match(/(Android)\s+([\d.]+)/), isMobile = isIphone || isAndroid; if (isMobile) { if (isWeixin) { document.body.innerHTML = '< div id="container" style="display: block;">< div style="position:relative;padding-top:140px;color:#333;font-size: 20px;text-align: center;">< i style="position: absolute;top: 10px;right: 40px;font-size: 80px" class="iconfont icon-jiantou"></ i >< p style="font-weight: 600;">请点击屏幕右上角 [ ··· ]</ p >< p >在< i style="font-size: 30px;color: #1487F0" class="iconfont icon-browser"></ i > 浏览器打开网页</ p >< br >< p style="color:red;">请在浏览器打开本网页哦~</ p ></ div ></ div >'; } } </ script > </ body > </ html > |
文章转自https://www.wpon.cn/26303.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
2021-03-01 获取一个月有多少天 ---- 获取一个月的第一天和最后一天 yyyy-mm-dd