$(document).ready(function($){ var deviceAgent = navigator.userAgent.toLowerCase(); var agentID = deviceAgent.match(/(iphone|ipod|ipad)/); if (agentID) { //do something } });
Mobile Device Detection with jQuery
3 responses to “Mobile Device Detection with jQuery”
Leave a Reply
You must be logged in to post a comment.
//do something…
alert (‘nice mock turtleneck, dork’);
I’ve been doing some looking and I couldn’t find a way to add other devices other than iOS to the above code. If anyone else has insight into this, please comment. Or if you know of other ways to detect different mobile browsers, please start a new post detailing how to do it.
Darin, make that function print the var deviceAgent = navigator.userAgent.toLowerCase(). Then go to there with any browser. Add the results to that array. Yes / No?