Java script detect Touch-screen devices

When you are developing web sites for compatibility all browsers and mobile devices.But sometimes you want to detect who viewing the site that using device is consisting with touch-screen or not.Here is a perfect,tested and easy example to detect touch screen devices.This was tested in lot of web browsers.

function is_touch_device() {
return !!('ontouchstart' in window);
}
var istouch = is_touch_device(); // call to above function
if(istouch==true) {
alert('touch-device');
}
else {
alert('no touch-device');
}

Also this method can be use to detect touch-screen devices.

var is_touch_device = 'ontouchstart' in document.documentElement;
if(is_touch_device==true) {
// touch screen
}
else {
// not touch screen
}

You can view Modernizr Touch events information from here.