如何限制帝国移动端只能在微信上打开?
如果我们需要帝国CMS做的网站只能在手机端微信浏览器打开,那么就需要以下步骤了,包括了一个判断方法(前台JS静态判断客户端)!
代码如下:
把以下js代码加到模板里头部
1 2 3 4 5 6 7 8 | <script type= "text/javascript" > if ( typeof WeixinJSBridge!== "undefined" ) {} else { if (screen.width>=1000){ var opened = window.open( '/wxError.html' , '_self' );} else {} } </script> |
然后在后台栏目-自定义页面-新建个自定义页面-命名为wxError.html
代码以下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!doctype html> <html> <head> <meta charset= "utf-8" > <meta content= "width=device-width,inital-scale=1.0,maximum-scale=1.0,user-scalable=no" name= "viewport" /> <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" rel= "nofollow noopener noreferrer" href= "https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css" > </head> <body> <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> </body> </html> |
到此这篇关于帝国CMS移动端限制只能在微信浏览器打开就介绍到这了。理想的路总是为有信心的人预备着。更多相关帝国CMS移动端限制只能在微信浏览器打开内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!