Socket
Socket
Sign inDemoInstall

uadetect

Package Overview
Dependencies
83
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    uadetect

The dead-simple way of detecting a device's User Agent


Version published
Weekly downloads
8
increased by14.29%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

UA-detect

Description

The dead-simple way of detecting a device's user agent.

Technologies Used

TypeScript jQuery

Installation

via npm

Install the uadetect package

npm i -d uadetect

In a JavaScript (or TypeScript) file, import the uadetect module:

import { DetectScreenOrientation, DetectDeviceType, finiteMobileDeviceType, ORIENTATION_isLandscape, DEVICE_type, DEVICE_finiteType } from 'uadetect';

All done. Now you can use the ORIENTATION_isLandscape, DEVICE_finiteType and DEVICE_type constraints in your code.

Usage

// An example hide element on mobile devices function
function hideOnMobile(element) {
    if (DEVICE_type == "mobile") {
        element.style.display = "none";
    }
}
// An example show element on different operating systems function
function showOnOS(element, element2) {
    if (DEVICE_finiteType == "iOS") {
        element.style.display = "block";
    }
    else if (DEVICE_finiteType == "Android") {
        element2.style.display = "block";
    }
    else {
        element.style.display = "none";
        element2.style.display = "none";
    }
}

Keywords

FAQs

Last updated on 13 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc