-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop support? #3
Comments
Can you tell me the value for |
With Node.js, here are the tests: Windows 7 Mac |
Maybe, I'm doing something wrong |
Can you double-check whether you call the constructor of MobileDetect "class" with the userAgent as argument? var md = new MobileDetect(window.navigator.userAgent); |
@alexmatveev to check for a desktop device you have to first check if it's mobile, hence isDesktop is not available. |
in route:
in view (jade):
|
@serbanghita But there are more options: TV, DesktopMode, Watch, etc. So I must to check all of them and if they all are FALSE, mean that it's a desktop? |
@alexmatveev you haven't done anything wrong. The problem you're encountering is, that MobileDetect has a strong focus on mobile devices and leaves desktop a bit in the dark. This means that You can see some "extensions" if you have a look at mobile-usage. Extending mobile-detect.js to classify desktop browsers and operating system would not be a bad idea. But at the moment I don't have a good idea how to keep backward compatibility. Any suggestion? |
bumping this. I started off using mobile detect for a responsive web app but now I need to have custom functionality on desktop |
Not sure if this help's but this how I have adapted the functionality to detect Desktop, Phone, Tablet and Mobile (Phone and Tablet) isMatchingDeviceType(device) {
if (typeof device === 'undefined') {
return true;
}
if (['ALL', 'MOBILE', 'PHONE', 'DESKTOP', 'TABLET'].indexOf(device) == -1 || device === "ALL") {
return true;
}
var md = new MobileDetect(this.userAgent);
var isMobile = md.mobile() !== null, isPhone = md.phone() !== null, isTablet = md.tablet() !== null;
if (device === "DESKTOP" && !isMobile) {
return true;
}
if (device === "MOBILE" && isMobile) {
return true;
}
if (device === "TABLET" && isTablet) {
return true;
}
if (device === "PHONE" && isPhone) {
return true;
}
return false;
} |
I would suggest a separate library ( |
Why when using with desktop, these functions give blank result:
userAgent()
os()
And is this possible to do something like md.is('Desktop')?
The text was updated successfully, but these errors were encountered: