如题所述
第1个回答 2017-03-15
/**
* 获取客户端信息
*/
function getClientInfo(){
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var agentinfo = null;
for (var i = 0; i < Agents.length; i++) {
if (userAgentInfo.indexOf(Agents[i]) > 0) { agentinfo = userAgentInfo; break; }
}
if(agentinfo){
return agentinfo;
}else{
return "PC";
}
}
//调用示例
alert( getClientInfo() );本回答被提问者采纳
* 获取客户端信息
*/
function getClientInfo(){
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var agentinfo = null;
for (var i = 0; i < Agents.length; i++) {
if (userAgentInfo.indexOf(Agents[i]) > 0) { agentinfo = userAgentInfo; break; }
}
if(agentinfo){
return agentinfo;
}else{
return "PC";
}
}
//调用示例
alert( getClientInfo() );本回答被提问者采纳
第2个回答 2017-03-14
判断客户端的宽度来判断是什么设备,可以直接用@media