有時(shí)候我們需要帝國CMS做的網(wǎng)站只能在手機(jī)端微信瀏覽器打開,那么就需要以下步驟了,包括了一個(gè)判斷方法(前臺(tái)JS靜態(tài)判斷客戶端)!
代碼如下:
把以下js代碼加到模板里頭部
<script type="text/javascript">
if( typeof WeixinJSBridge!== "undefined" ) {}
else
{
if(screen.width>=1000){var opened = window.open('/wxError.html', '_self');}
else{}
}
</script>
然后在后臺(tái)欄目-自定義頁面-新建個(gè)自定義頁面-命名為wxError.html
代碼以下:
<!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>抱歉,出錯(cuò)了</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<link rel="stylesheet" type="text/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">請?jiān)谖⑿趴蛻舳舜蜷_鏈接</h4></div></div>
</body>
</html>