Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

uadetect

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uadetect

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

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by175%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 13 Apr 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc