[英]How do I determine if a device is a desktop browser?
I am creating a responsive design for a website. 我正在为网站创建响应式设计。 We have a rollover navigation menu for non-touch desktop browsers and an off canvas menu design for touch mobile and touch tablets.
我们为非触摸式桌面浏览器提供了一个过渡导航菜单,为触摸移动和触摸平板提供了非画布菜单设计。 It is an ASP.NET MVC4 project.
这是一个ASP.NET MVC4项目。 How can I determine in C#, Javascript, or CSS3 if a user is browsing the site with a desktop browser?
如果用户使用台式机浏览器浏览网站,如何确定C#,Javascript或CSS3? I would prefer to use some kind of CSS3 media query if it is possible.
如果可能的话,我宁愿使用某种CSS3媒体查询。
From a beautiful site: http://www.abeautifulsite.net/blog/2011/11/detecting-mobile-devices-with-javascript/ 在一个美丽的网站上: http : //www.abeautifulsite.net/blog/2011/11/detecting-mobile-devices-with-javascript/
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
if(isMobile.any()){
// Mobile!
} else {
// It is desktop
}
Else use libraries like device.js http://matthewhudson.me/projects/device.js/ 其他使用诸如device.js的库http://matthewhudson.me/projects/device.js/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.