Search
 
SCRIPT & CODE EXAMPLE
 

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());
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 :: detect button click jquery 
Javascript :: nodejs delete folder recursively 
Javascript :: ajax clear form 
Javascript :: regex expression dd/mm/yyyy javascript 
Javascript :: how get a json object from an api in javascript 
Javascript :: npm react-dom 
Javascript :: nodejs put array in file 
Javascript :: react native detect production 
Javascript :: mongoose connect database name 
Javascript :: pdf.js cdn 
Javascript :: how to get date time day year in javscript 
Javascript :: javascript check if value is not empty string 
Javascript :: Use Recursion to Create a Countdown 
Javascript :: javascript convert number to binary 
Javascript :: scroll to top jquery 
Javascript :: parse integer javascript 
Javascript :: js number validation 
Javascript :: javascript check if all capital letter 
Javascript :: disable default sorting in datatable 
Javascript :: solid icons in next js 
Javascript :: javascript remove last character 
Javascript :: jquery click event 
Javascript :: uniqid js 
Javascript :: usehistory not found in react-router-dom 
Javascript :: how to update node modules 
Javascript :: javascript custom events with data 
Javascript :: How to remove text from a string in javscript 
Javascript :: js replace non a-z 
Javascript :: updatedAt 
Javascript :: javascript reserved words 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =