注意:这个办法并非最优选择,弊端在于对搜索引擎并不友好,因为加载资源后再跳转,增加了用户访问成本。建议使用301重定向来处理
function GetUrlRelativePath()
{
var url = document.location.toString();
var arrUrl = url.split("//");
var start = arrUrl[1].indexOf("/");
var relUrl = arrUrl[1].substring(start);
if(relUrl.indexOf("?") != -1){
relUrl = relUrl.split("?")[0];
}
return relUrl;
}
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone","SymbianOS", "Windows Phone","iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
if (!flag){
location.href="/m"+GetUrlRelativePath();;
}
正文完
要饭中,多少给点吧(支付宝)