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 :: How to fix stomp websocket error 
Javascript :: jquery remove keypress event 
Javascript :: vue test form input 
Javascript :: execute JS code after pressing space bar 
Javascript :: await inside map js 
Javascript :: electron Uncaught ReferenceError: require is not defined at recorder.js:1 
Javascript :: mktime in js 
Javascript :: how to get back image and front text in react native 
Javascript :: get the last item in object javascript 
Javascript :: js remove first and last element from array 
Javascript :: append before parent jquery 
Javascript :: react native text input number only 
Javascript :: split a message 
Javascript :: Update nextjs to 11 
Javascript :: how to add a shadow react native 
Javascript :: tailwind in react 
Javascript :: map with promise.all 
Javascript :: javascript camera 
Javascript :: Javascript console log a int 
Javascript :: encodeurl in javascript 
Javascript :: parse int into 2 digits format javascript 
Javascript :: get caret position javascript 
Javascript :: padend method in javascript 
Javascript :: stop from from refresching page react 
Javascript :: save token in localstorage 
Javascript :: for in object javascript 
Javascript :: infinite loop in programming 
Javascript :: javascript html encode 
Javascript :: js 2d array to object 
Javascript :: javascript remove all style values in div 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =