Reputation: 2070
if ( (navigator.userAgent.indexOf('/iPadi') != -1) ) {
}
I use this if statement to detect if user agent is iPad but I only want to run code if it is not iPad. I have JQuery hover that i want to use in all cases except iPad, where I want to use touch gestures. In this case I would put the hover()
function in and if statement to run only if not iPad.
Upvotes: 0
Views: 1339
Reputation: 811
This statement will do the job as well:
var isIpad = navigator.userAgent.match(/iPad/i) != null;
Upvotes: 0
Reputation:
In my project I use this and it works. No need for regex:
if ( navigator.userAgent.indexOf('iPad') == -1 )
{
}
Upvotes: 4
Reputation: 6968
u want to use a regex.
if ( (navigator.userAgent.match(/iPad/i) <= 0) ) {
Upvotes: 0