Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mobile-detect-js

Another loose port of https://github.com/serbanghita/Mobile-Detect for Javascript, to get latest detections. As https://github.com/hgoebl/mobile-detect.js doesn't update anymore.

Both great projects!

Notes

  • HTTP headers' code is removed
  • caching code is removed
  • exceptions are removed
  • regular expressions are simplified in the build.php so that there's no sub-arrays to parse

Installation

Just copy the mobile-detect.js or the minimized version mobile-detect.min.js into your project. You can use the raw link for direct download (link is available by clicking on the file above, then there's a Raw button).

Usage

// fallsback to navigator.userAgent
var md = new MobileDetect();

// or set it explicitly
var md = new MobileDetect('Mozilla/5.0');

Then you can use the (currently) implemented methods:

md.isMobile(); // or md.is('mobile')
md.isPhone(); // or md.is('phone')
md.isTablet(); // or md.is('tablet')

For dedicated checks, you have the full set of names here: methods in PHP project But do NOT use the md.isiPhone() statement, it's not implemented. You MUST always use the md.is('iPhone') method instead.

md.is('iPhone'); // or md.is('iphone'), it's case-insensitive
md.is('AndroidOS');

About

Loose port of https://github.com/serbanghita/Mobile-Detect to get latest detections as https://github.com/hgoebl/mobile-detect.js doesn't update anymore. Both great projects!

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages