Saturday, May 25, 2013

Detect if device support Touch using Javascript

To detect if the device support Touch with Javascript:

<!DOCTYPE html>

<html>
<head>
    <title>Page Title</title>
</head>
<body>
    
    <header id="header" role="banner">
        <h1><a href="/">Hello!</a></h1>
        
    </header>


<script>
    if ("ontouchstart" in window) {
        alert("Touch Start");
    }
    
</script>
</body>
</html>


("ontouchstart" in window)
Detect if device support Touch using Javascript

No comments:

Post a Comment