asp判断是否移动端_asp判断用户端是电脑访问还是移动设备方法
展開全部
直接用JS更方便,更準確,
ASP
if?InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0?then
response.redirect??"wap.asp"?'如果是手機訪問則跳轉到32313133353236313431303231363533e59b9ee7ad9431333363353765wap.asp
response.end
else
response.redirect??"default.asp"?'如果電腦訪問跳轉到首頁
response.end
end?if
%>
JSfunction?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|SymbianOS)/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
}
}
}
};
使用方法:
以上的JS是以前在百度抓下,現在不知道還是不是用這個,,你搜索一下JS判斷PC手機,可以找到蠻多,有些更簡單。。
總結
以上是生活随笔為你收集整理的asp判断是否移动端_asp判断用户端是电脑访问还是移动设备方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ubuntu20.05安装vmware
- 下一篇: Uniapp进行APP打包——iOS 系