How to detect a mobile browser using jQuery or some other way.

Possible duplicate: the
best way to detect a handheld device in jQuery

I want to make a mobile version of my web application. How can I run a function that will determine if the request is being executed from the desktop or mobile browser?

This is so that if the user requests from a mobile browser, and they click on the link, rather than go to the actual page, it should be captured and make another event.

Thanks in advance.

+5
source share
2 answers

, JavaScript jQuery.

+8

,

navigator.platform

navigator.appName

:

// Detects if it is an Android device
var android = (navigator.platform.indexOf("android")>=0);
if (android) {
   // Do something
}

, JQuery , , .

+7

All Articles