Chris
Chris

Reputation: 453

iPad user agent detection

Is there a way of detecting the first generation iPad exclusively using either javascript or PHP?

I need to use some fallback javascript on the first gen iPads, as the newer iPads are fine.

Upvotes: 1

Views: 187

Answers (2)

mohsin139
mohsin139

Reputation: 1027

In PHP you can detect iPad with the following.

if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
   echo "Its an iPad";
}

Upvotes: 2

meda
meda

Reputation: 45490

<script>
    if (/Apple-iPad/i.test(navigator.userAgent)) {
        //iPad first generation detected!
    }
</script>

Upvotes: 0

Related Questions