Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get device type 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: #device #type #javascript
ADD COMMENT
Topic
Name
9+5 =