Modernizr reporting laptop as touch device in Chrome and FF

不羁的心 提交于 2019-12-01 00:01:11

问题


Bit of a weird one. I have a site I am working on. But, on my laptop (ASUS Zenbook) some of the features do not work. We spent a good amount of time using Firebug to try and get it working/work out what it was, with no joy!

I then noticed that these features were actually created in CSS using :hover classes, but were also disabled for touch devices by including the class ".no-touch".

I then looked at the classes that Modernizr had added to the HTML tag and ".touch" had been added along with the standard.

So it seems, Modernizr is viewing my laptop, in Firefox and Chrome, as a touch device.

Obviously, this could be an issue for when the site goes live in that some features will not work for anyone using a Zenbook and any other devices that acts in the same way.

Has anyone seen anything like this before? Maybe with other "non-touch" devices?


回答1:


Unfortunately Modernizr tests for support of Touch-events in the browser, so it's not a proper test for a touch device. Last builds of Chrome and Firefox are supporting this feature.

You can check the issue here: https://github.com/Modernizr/Modernizr/issues/548

I'm searching for a good solution on this matter too, but the only thing I've found is this, though I haven't tested it out yet: https://stackoverflow.com/a/4819886/1262357

If you have good results please let me know!



来源:https://stackoverflow.com/questions/13530612/modernizr-reporting-laptop-as-touch-device-in-chrome-and-ff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!