What's the best way to detect a 'touch screen' device using JavaScript?

后端 未结 30 2905
花落未央
花落未央 2020-11-21 23:50

I\'ve written a jQuery plug-in that\'s for use on both desktop and mobile devices. I wondered if there is a way with JavaScript to detect if the device has touch screen capa

30条回答
  •  野性不改
    2020-11-22 00:22

    All browser supported except Firefox for desktop always TRUE because of Firefox for desktop support responsive design for developer even you click Touch-Button or not!

    I hope Mozilla will fix this in next version.

    I'm using Firefox 28 desktop.

    function isTouch()
    {
        return !!("ontouchstart" in window) || !!(navigator.msMaxTouchPoints);
    }
    

提交回复
热议问题