Alex Borsody
Alex Borsody

Reputation: 2070

run code if NOT iPad

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

Answers (3)

hennson
hennson

Reputation: 811

This statement will do the job as well:

var isIpad = navigator.userAgent.match(/iPad/i) != null;

Upvotes: 0

user1796666
user1796666

Reputation:

In my project I use this and it works. No need for regex:

  if ( navigator.userAgent.indexOf('iPad') == -1 )
  {

  }

Upvotes: 4

j_mcnally
j_mcnally

Reputation: 6968

u want to use a regex.

if ( (navigator.userAgent.match(/iPad/i) <= 0) ) {

Upvotes: 0

Related Questions