[JS] 偵測設備是否支援觸控

$(document).ready(function() {
var $body = $(‘body’);
var detectMouse = function(e){
if (e.type === ‘mousedown’) {
alert(‘Mouse interaction!’);
}
else if (e.type === ‘touchstart’) {
alert(‘Touch interaction!’);
}
// remove event bindings, so it only runs once
$body.off(‘mousedown touchstart’, detectMouse);
}
// attach both events to body
$body.on(‘mousedown touchstart’, detectMouse);
});

參考來源:http://stackoverflow.com/questions/7838680/detecting-that-the-browser-has-no-mouse-and-is-touch-only

廣告

最近要survey的東東

http://code.angularjs.org/

http://egghead.io/ Angular course

http://angular-ui.github.io/ng-grid/ Angular grid

http://morlay.tla42.org/coding/2013/02/20/AngularJS-Core/ Angular核心

http://morlay.tla42.org/coding/2013/03/01/AngularJS-Socket.IO/

http://expressjs.com/

http://sailsjs.org/

https://www.firebase.com/

http://mongodb.github.io/node-mongodb-native/

http://cnodejs.org/topic/5206581b44e76d216aae072e

javascript getter setter

http://robertnyman.com/javascript/javascript-getters-setters.html

http://ejohn.org/blog/javascript-getters-and-setters