Free Photos
WordPress Themes

Detect device type using JavaScript

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { // Do something } else { // Do something else }
Dead simple snippet that shows how to detect if user is using a mobile device or a desktop to view your webpage.

#javascript #deviceDetector #mobile


2 Responses

Incorrect title, jQuery not used in this case. It is just javascript. Very useful.
@Marco Pinero Fixed, thanks =)

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.