Site Overlay

Check is touch device using javascript

To check is user browsing from the touch device here is snippet for that. So you can add your custom classes to the body.

function isTouchDevice(){
  return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
if(isTouchDevice()===true) {

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2022 Dip Codes. All Rights Reserved.