Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check device type in javascript

const detectDeviceType = () =>
   /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
      navigator.userAgent
   )
      ? 'Mobile'
      : /(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(
           navigator.userAgent
        )
      ? 'Tablet'
      : 'Desktop';
console.log(detectDeviceType());
Source by github.com #
 
PREVIOUS NEXT
Tagged: #check #device #type #javascript
ADD COMMENT
Topic
Name
6+5 =