Closed stormisover closed 7 years ago
The existing code takes the route of "feature detection" which is a more appropriate solution than "User Agent detection" (which is considered to be a bad practice).
If there are issues with the feature detection, please consider improving the feature detection mechanism.
According to Mozilla, navigator.userAgent is deprecated and has been removed from modern web standards: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID/userAgent
Yeah, I don't really like this solution.
The main problem here is indeed touch-enabled Windows machines. The only real solution I can find is the (not yet fully supported) Pointer Events
.
See https://github.com/CWSpear/bootstrap-hover-dropdown/blob/3.0/bootstrap-hover-dropdown.js
It's impossible to create an automated test for this sort of thing as far as I can tell, and I don't have a way to manually test every browser/OS combo.
I agree my solution are not nice enough because it has to enumerate all the OS name. However, I searched many solutions, this seems a common method.
For example, https://github.com/hgoebl/mobile-detect.js/
How could we bypass the mobile device perfectly?
The problem is we don't want to detect mobile. Or that is to say, that doesn't solve our issue. It's a complicated issues. That's why new technology at the browser level (Pointer Events) had to be created.
Good to know. Thanks!
Use useAgent to detect device type instead of touch event.