1、网站页面中插入以下代码,可直接将不需要指定UA访问的页面插入以下代码,或者将代码插入公共页面头部或者尾部代码中
<script> var system = { win: false, mac: false, xll: false }; var p = navigator.platform; var us = navigator.userAgent.toLowerCase(); system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); if (system.win || system.mac || system.xll) { var iframe_url='/addons/404.htm'; $("title").html('404'); $("head").append('<style>body{position:static !important;}body *{ visibility:hidden; }</style> '); $("body").empty(); $(document).ready(function () { $("body").html('<iframe style="width:100%; height:100%;position:absolute;margin-left:0px;margin-top:0px;top:0px;left:0px;" id="mainFrame" src="'+iframe_url+'" frameborder="0" scrolling="no"></iframe>').show(); $("body *").css("visibility", "visible"); }); } </script>
2、在网站根目录中新建目录addons,在其目录下新建html页面404.htm,插入以下404页面代码,或者自定义代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>网站访问报错</title> <style type="text/css"> * { padding:0; margin:0;} li { list-style:none;} img { border:none;} .clear { zoom:1;} .clear:after { content:''; clear:both; display:block;} .error-page { width:940px; margin:0 auto; padding-top:110px;} .error-page-right { width:500px; float:left;} .error-page-right h3 { line-height:114px; font-size:22px; color:#333; font-weight:600; padding-top:10px;} .error-page-title { line-height:24px; font-size:14px; color:#333;} .error-page-title a { color:#0066cc; text-decoration:underline;} .error-page-txt { line-height:24px; padding-left:40px; font-size:14px; color:#333; padding-bottom:9px;} .error-page-txt a { color:#0066cc; text-decoration:underline;} </style> </head> <body> <div class="error-page"> <div class="error-page-left"> </div> <div class="error-page-right"> <h3>抱歉!该网站可能由于以下原因无法访问!</h3> <p class="error-page-title">>>1、您访问的域名未绑定至主机;</p> <p class="error-page-txt">解决方法:需要网站管理员登录<a href="https://cp.hichina.com/" target="_blank">万网主机控制面板</a>绑定域名,阿里云账号请登录<a href="https://netcn.console.aliyun.com/core/host/list2" target="_blank">阿里云虚拟主机控制台</a>绑定。</p> <p class="error-page-title">>>2、您正在使用IP访问;</p> <p class="error-page-txt">解决方法:请尝试使用域名进行访问。</p> <p class="error-page-title">>>3、该站点已被网站管理员停止;</p> <p class="error-page-txt">解决方法:需要网站管理员登录<a href="https://cp.hichina.com/" target="_blank">万网主机控制面板</a>开启站点,阿里云账号请登录<a href="https://netcn.console.aliyun.com/core/host/list2" target="_blank">阿里云虚拟主机控制台</a>进行开通。</ </div> </div> </body> </html>