您的位置:首页 > 其它

百度判断手机访问还是PC访问

2017-05-30 10:43 357 查看
JS代码
   function uaredirect(f) {try {if (document.getElementById("bdmark") != null) {return}var b = false;if (arguments[1]) {var e = window.location.host;var a = window.location.href;if (isSubdomain(arguments[1], e) == 1) {f = f + "/#m/" + a;b = true} else {if (isSubdomain(arguments[1], e) == 2) {f = f + "/#m/" + a;b = true} else {f = a;b = false}}} else {b = true}if (b) {var c = window.location.hash;if (!c.match("fromapp")) {if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))) {location.replace(f)}}}} catch(d) {}}function isSubdomain(c, d) {this.getdomain = function(f) {var e = f.indexOf("://");if (e > 0) {var h = f.substr(e + 3)} else {var h = f}var g = /^www\./;if (g.test(h)) {h = h.substr(4)}return h};if (c == d) {return 1} else {var c = this.getdomain(c);var b = this.getdomain(d);if (c == b) {return 1} else {c = c.replace(".", "\\.");var a = new RegExp("\\." + c + "$");if (b.match(a)) {return 2} else {return 0}}}};
引用  <script src="js/uaredirect.js" type="text/JavaScript"></script><script type="text/javascript">uaredirect("自己的网页地址 如//http://119.23.210.173:8080/jsp/phone/index.jsp");</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: