mike jones
mike jones

Reputation: 659

Detect mobile phone by seeing if viewport is respected

Hi sorry if this is already asked. But I looked around quite a bit.

The methods I have found for detecting if a web user is using a mobile phone don't seem very nice. They are: look at the user agent string (hackish), look for a narrow width (but what's narrow?).

Is there a direct way to see if the browser supports the <meta viewport...> directive? I think that would be the best way. Because that's what we want... If the browser supports viewport (i.e. is mobile) use it. Otherwise not.

Upvotes: 0

Views: 1452

Answers (1)

Krumelur
Krumelur

Reputation: 32497

Try this one: http://detectmobilebrowser.com/

The meta viewport is seems to be implemented differently from the CSS attributes, so any solution involving reading the viewport width before specifying it may not be portable.

Upvotes: 1

Related Questions