Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

find 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());
Comment

get device type using javascript

const getDeviceType = () => {
  const ua = navigator.userAgent;
  if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) {
    return "tablet";
  }
  if (
    /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(
      ua
    )
  ) {
    return "mobile";
  }
  return "desktop";
};
Comment

javascript get device

window.navigator.userAgent
Comment

PREVIOUS NEXT
Code Example
Javascript :: expo create react native app 
Javascript :: typescript round 
Javascript :: divide intagers javascript 
Javascript :: jquery add div element 
Javascript :: get the last option from select jquery 
Javascript :: react function with form 
Javascript :: js remove after character 
Javascript :: console log style 
Javascript :: yellowbox react native 
Javascript :: load script js 
Javascript :: unpack array into variables javascript 
Javascript :: jquery set route with parameters in url 
Javascript :: js paste event 
Javascript :: react native run ios select simulator 
Javascript :: javascript get hostname from current url 
Javascript :: how to generate random character from an array js 
Javascript :: how to select a random value in a json array LUA 
Javascript :: js touch relative pos 
Javascript :: jquery how to fnd id 
Javascript :: disabled javascript 
Javascript :: base64 to string and string to base64 javascript decode 
Javascript :: generate random alphanumeric string javascript 
Javascript :: react how to scroll to element 
Javascript :: jquery get current row value 
Javascript :: equation+ automate + expression reguliere 
Javascript :: import withrouter 
Javascript :: js get location search parameter 
Javascript :: hide warnings in expo app 
Javascript :: - Root composer.json requires tymon/jwt-auth ^0.5.12 - satisfiable by tymon/jwt-auth[0.5.12]. 
Javascript :: javascript regular expression flags 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =