这个功能是利用百度的一个app应用,一个js文件 http://siteapp.baidu.com/static/webappservice/uaredirect.js 或 http://download.csdn.net/detail/evasunny2008/9699737
使用方法: 1、引用这个js文件,不管是直接用外网的,还是下面本地都行。 2、在页面里调用方法uaredirect(“手机网址”)
完全的代码
<script src="uaredirect.js" type="text/javascript"></script> <script type="text/javascript">uaredirect("手机网址");</script>这种方法也适用:(遇到一种情况不可用,PC版为响应式网站时不可用)这段js加在<head></head>内<script type="text/javascript">
//平台、设备和操作系统 var system = { win: false, mac: false, xll: false }; //检测平台 var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); //跳转语句,如果是手机访问就自动跳转到wap.baidu.com页面 if (system.win || system.mac || system.xll) {
} else { window.location.href = "/Phone/";//手机访问地址
}</script>
转载于:https://www.cnblogs.com/Stillwatersrundeep/p/6774494.html