Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 477 Bytes

how_do_you_detect_a_mobile_browser.md

File metadata and controls

17 lines (10 loc) · 477 Bytes

How do you detect a mobile browser?

You can detect a mobile browser by checking the navigator.userAgent string for keywords like 'mobile', 'Android', or 'iPhone'.

Example:

if (/Mobi/.test(navigator.userAgent)) {
  console.log('Mobile browser detected');
}

Tags: basic, JavaScript, mobile detection