2014-11-24 91 views

回答

4

您可以使用navigator

function is_touch_device() { 
return (('ontouchstart' in window) 
     || (navigator.MaxTouchPoints > 0) 
     || (navigator.msMaxTouchPoints > 0)); 
} 

if (is_touch_device()) { 
    alert("Yay! Its touch"); 
}else{ 
    alert("Not touch!") 
} 

完整的源:http://ctrlq.org/code/19616-detect-touch-screen-javascript

相關問題