JaveScript 前端最快的判断来路是否为搜索引擎跳转方法,比后端 PHP 之类的判断快
代码如下
var echo = function(str) { document.write(str); } var regexp = /\.(baidu|haosou|sogou|soso|google|youdao|yahoo|bing|biso|gougou|ifeng|ivc|sm|360|so)(\.[a-z0-9\-]+){1,2}\//ig; var where = document.referrer; if (regexp.test(where)) { var r = document.referrer; if ((navigator.userAgent.match(/(Android|android|Linux)/i))) { window.location.href = 'android.html' } else if ((navigator.userAgent.match(/(iPhone|iPad|iPod|ios)/i))) { window.location.href = 'ios.html' } else { window.location.href = 'pc.html' } } if ((navigator.userAgent.match(/(Android|android|Linux)/i))) { window.location.href = 'android.html' } else if ((navigator.userAgent.match(/(iPhone|iPad|iPod|ios)/i))) { window.location.href = 'pc.html' }